1

I have the following code

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("start-maximized")
options.add_argument("enable-automation")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-infobars")
options.add_argument("--disable-gpu")
options.add_argument("--disable-browser-side-navigation")
driver = webdriver.Chrome(options=options)

which returns the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

If I run with options.add_arguments("--headless"), I don't receive any error. Unfortunately, I can't really run what I'd like to in headless. Does anybody have any ideas?

pete
  • 561
  • 6
  • 16

1 Answers1

1

ChromeDriver isn't finding the port it needs to talk to Chrome over.

Solution : Check your chrome browser version and then you can download chromedriver from the below location.

https://chromedriver.chromium.org/downloads

Useful link : https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection

SeleniumUser
  • 4,065
  • 2
  • 7
  • 30
  • 1
    In `usr/bin` I see that the Google Chrome version is Google Chrome 78.0.3904.108 and the Chrome Driver is ChromeDriver 78.0.3904.108, though – pete Dec 01 '19 at 03:01
  • Are you running your test in headless mode. if not then add options.add_argument('--headless') – SeleniumUser Dec 01 '19 at 07:11
  • 1
    No, I'm specifically trying to use Chrome out of headless mode. Could it have to do with the display? – pete Dec 01 '19 at 14:33
  • @pete were you able to find a solution? I am in the same boat, trying to run Chrome in non-headless mode while using xvfb and getting the same error – Prashant Sengar Jan 06 '22 at 10:21