4
votes

Just to show that I have done my due diligince, I have already either tried the suggested answers or at least read them over and tried to understand, for the following questions:

Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed

The process started from chrome location C:\..\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed

Selenium python library via docker, Chrome error failed to start: exited abnormally

Chrome crashes when using Selenium (No answer posted but I still looked it over)

How to fix "usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed" error in Linux? - For this one I substituted the '/usr/bin/google-chrome' with '/etc/alternatives/google-chrome', still didn't work.

The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed for Selenium

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed with ChromeDriver and Selenium in Python

python linux selenium: chrome not reachable

unknown error: Chrome failed to start: crashed(selenium ,headless mode)

python selenium: WebDriverException: Message: chrome not reachable

Selenium chrome failed to start

WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS

Getting "Chrome not reachable" error while executing test scripts in Selenium Grid With Chrome browser

Selenium webdriver error Chrome failed to start

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed (headless chrome)

Python : Selenium - Message: unknown error: Chrome failed to start: exited abnormally

I am getting a common error that I have seen here on Stack Overflow, when running Selenium with Python on my Amazon Linux server I get the following results:

Traceback (most recent call last):
  File "test-selenium-chrome.py", line 15, in <module>
    driver = webdriver.Chrome(options=options, executable_path='/usr/local/bin/chromedriver')  # Optional argument, if not specified will search path.i
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/site-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: crashed
  (chrome not reachable)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Here is my code:

#!/usr/bin/python3
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from pyvirtualdisplay import Display

options = Options()
options.binary_location = '/usr/bin/google-chrome'
options.add_argument('--disable-extensions')
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--remote-debugging-port=9515')
options.add_argument('--disable-setuid-sandbox')

display = Display(visible=0, size=(800, 800))
display.start()

driver = webdriver.Chrome(options=options, executable_path='/usr/local/bin/chromedriver')  # Optional argument, if not specified will seearch path.i
driver.maximize_window()
driver.get('http://www.google.com/')
time.sleep(5)  # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5)  # Let the user actually see something!
driver.quit()

I am using Google Chrome version 79.0.3945.130, and the corresponding chromedriver version ChromeDriver 79.0.3945.36 as speicified in https://sites.google.com/a/chromium.org/chromedriver/downloads

Additional info, if I just run google-chrome from the command line, I get:

[ec2-user@ip-xxx-xx-xx-xxx bin]$ pwd
/usr/bin
[ec2-user@ip-xxx-xx-x-xxx bin]$ google-chrome
Segmentation fault

Any help is greatly appreciated.

2
Have you tried with the latest chrome driver version?Muzzamil
Hi Muzzamil, yes I tried it with the chromedriver version 80.0.3987.16. Still got the same results.Brent Heigold
Okay and sequence of chrome driver binary path and chrome options is correct in webdriver.Chrome()? I think path should come first and then options.Muzzamil
Hi Muzzami, I just reversed the order and tried driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', options=options) that still didn't work.Brent Heigold
Anyone is getting this error in github actions( deployment section)Anupam Haldkar

2 Answers

2
votes

This error message...

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
  (chrome not reachable)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.


As per the discussion in Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed, the expected default location of on is:

/usr/bin/google-chrome

Note: For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.

So ideally, the following minimal code block should have worked:

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

options = Options()
options.binary_location = '/usr/bin/google-chrome'
driver = webdriver.Chrome(options=options, executable_path='/usr/local/bin/chromedriver')
driver.get('http://www.google.com/')

But it seems, when you try to initiate a Chrome session manually, Segmentation fault occurs i.e. crashes as follows:

[ec2-user@ip-xxx-xx-xx-xxx bin]$ pwd
/usr/bin
[ec2-user@ip-xxx-xx-x-xxx bin]$ google-chrome
Segmentation fault

Segmentation fault

Segmentation fault (shortened as segfault) or access violation is a fault or failure condition raised by hardware with memory protection, notifying an operating system that the software has attempted to access a restricted area of memory. The OS kernel will, in response, usually perform some corrective action, generally passing the fault on to the offending process (your script) by sending the process a signal.

In short, it’s a helper mechanism to restrict programs/scripts from corrupting the memory which does not belong to it. See more here.


Reason and Solutions

The pottential reasons and solutions are:

  • Chrome is not at all installed within the system, so you have to install Chrome
  • Chrome is not installed at the default location, so you have to pass the correct location of chrome executable through binary_location property.
  • The symlink /usr/bin/google-chrome to the actual Chrome binary got corrupted, so you may have to create the symlink.
  • The user doesn't have required access rights /usr/bin/google-chrome, so you have provide the access rights.
0
votes

I had the same problem, just remove --headless line and it's work well.