Home > Enterprise >  chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed error using S
chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed error using S

Time:12-25

Before I begin: I know there are a billion posts about Selenium not working, and various solutions to try. I believe I've tried everything, but forgive me if I am missing something. I'm hitting my head against a wall and would appreciate help.

Here are some steps I have taken:

I downloaded the chromedriver for selenium (Ubuntu, Python) and used chmod 755 and also chmod 777 to make the driver executable. Afterwords, I started the chromedriver with ./chromedriver.

I've tried various options for Selenium, including manually adding the port that the chromedriver is running on

from selenium import webdriver

options = webdriver.ChromeOptions()
options.binary_location = "/home/myname/projects/myproject/chromedriver"
options.add_argument("--remote-debugging-port=9515")
chrome_driver_binary = '/home/myname/projects/myproject/chromedriver'
driver = webdriver.Chrome(chrome_driver_binary, options = options)
driver.get('http://www.ubuntu.com/')

I've tried options suggested in other posts, like these:

options.add_argument('--no-sandbox')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument("--disable-setuid-sandbox")

I've made sure that I am using a chromedriver that is compatable with my version of Chrome.

Nothing has seemed to work. I keep getting this error:

WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (chrome not reachable)
  (The process started from chrome location /home/myname/projects/myproject/chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

I'd sincerely appreciate someone else's interpretation of this problem.

CodePudding user response:

You need to take care of a couple of things as follows:

  • options.binary_location: Refers to the binary location and is used if Google Chrome isn't installed at the default location. See: WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome

  • --remote-debugging-port: If you aren't remote debugging, you can drop this argument safely.

  • chrome_driver_binary: Referes to the absolute location of the ChromeDriver within your system.

  • webdriver.Chrome(chrome_driver_binary, options = options): Additionally you may like to add the key executable_path as as follows:

    chrome_driver_binary = '/home/myname/projects/myproject/chromedriver'
    driver = webdriver.Chrome(executable_path=chrome_driver_binary, options = options)
    driver.get('http://www.ubuntu.com/')
    
  • --no-sandbox, --headless, --disable-dev-shm-usage, --disable-setuid-sandbox, etc are optional settings which you may not require to start off.

The minimum code block to initiate a Selenium driven ChromeDriver initiated Browsing Context can be:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
driver = webdriver.Chrome(executable_path='/home/myname/projects/myproject/chromedriver', options=options)
driver.get("http://www.ubuntu.com/")

A common cause for Chrome to crash during startup is running Chrome as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.


References

You can find a couple of relevant detailed discussions in:

  • Related