5

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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Brent Heigold
  • 1,213
  • 5
  • 24
  • 50

2 Answers2

3

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.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Hi DebanjanB, I tried changing the ownership of /usr/bin/google-chrome to ec2-user:apache, and I still get the segmentation fault. – Brent Heigold Feb 06 '20 at 14:56
  • Just to do my due diligence, I have installed it as the solution suggested, with the path to the working symbolic link correctly specified in the code (options.binary_location = '/usr/bin/google-chrome') – Brent Heigold Feb 06 '20 at 17:55
  • @BrentHeigold Are you able to spin up a Chrome browsing context manually? – undetected Selenium Feb 06 '20 at 18:21
  • Hi Debanjan, it's installed remotely on my AWS instance, so I can only run it command-line, and I get that same segmentation fault as described in my original question. Is that what you mean? – Brent Heigold Feb 06 '20 at 18:32
  • @BrentHeigold Seems something is still missing. If you can't achieve it manually due to OS kernel complaining about `segfault`, there's nothing much Selenium can do on top of it. Let me know if you have any further questions. – undetected Selenium Feb 06 '20 at 19:35
  • 1
    Ok sounds great, thanks for at least helping me narrow down my troubleshooting options. – Brent Heigold Feb 06 '20 at 19:52
  • @BrentHeigold did you get a solution that works? I'm finding I get this issue for some tests that run once I upgraded to v81 of chrome and chromedriver. – dragonsfire May 17 '20 at 20:16
  • Hi dragonsfire, I did get a solution but it was a while ago so I don't remember what I did. – Brent Heigold May 19 '20 at 04:56
  • 1
    @dragonsfire Did you find the solution? – mouse_freak Jul 07 '21 at 08:06
  • I received this error in GitHub actions and wrote an answer to it here stackoverflow.com/a/70341965/6697714 @mouse_freak – NorahKSakal Dec 13 '21 at 23:20
-3

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

Eliya
  • 119
  • 8