3

I am trying to use headless chrome on a Linux Centos 7 server with selenium and python. I am getting the following error when trying to activate the driver:

Traceback (most recent call last):
  File "send_notif_marktplaats.py", line 128, in <module>
    main()
  File "send_notif_marktplaats.py", line 117, in main
    driver = activate_driver()
  File "send_notif_marktplaats.py", line 42, in activate_driver
    driver = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver", chrome_options=optionsChrome)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer
  (Session info: headless chrome=80.0.3987.116)

My versions:

  • Chromedriver version 80.0.3987.106
  • Google chrome 80.0.3987.116

Can someone help me out?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Execute chromedriver and chrome to see if you need to install some packages. – Alessandro_Russo Feb 19 '20 at 11:40
  • getting this error when executing chrome with sandbox `[0219/114121.573710:ERROR:nacl_helper_linux.cc(308)] NaCl helper process running without a sandbox! Most likely you need to configure your SUID sandbox correctly` – Tycho Koster Feb 19 '20 at 11:46
  • which options did you configure for the chrome browser? Why don't you use version 81? It won't work with version 80. – Manali Kagathara Feb 19 '20 at 11:47
  • I only used no-sandbox right now, but I tried these ones as well: `optionsChrome.add_argument("--headless") optionsChrome.add_argument("start-maximized") optionsChrome.add_argument("disable-infobars") optionsChrome.add_argument("--disable-extensions") optionsChrome.add_argument("--disable-gpu") optionsChrome.add_argument("--disable-dev-shm-usage") optionsChrome.add_argument("--no-sandbox")` – Tycho Koster Feb 19 '20 at 11:50
  • I will try version 81 – Tycho Koster Feb 19 '20 at 11:51
  • @ManaliKagathara Why does it not work on version 80? – Tycho Koster Feb 19 '20 at 12:00
  • only beta version available and it is not supporting it. – Manali Kagathara Feb 19 '20 at 12:06
  • did you fix this problem and how? @Tycho Koster – Dolphin Nov 28 '21 at 14:17

1 Answers1

2

This error message...

selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer
  (Session info: headless chrome=80.0.3987.116)

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


As per the discussion WebDriver 80.0.3987.16 can't open Chrome on Linux @triciac updated that, the implementation of ChromeDriver v80.0 looks for Chrome in the following order:

  1. locations->push_back(base::FilePath("/usr/local/sbin"));
  2. locations->push_back(base::FilePath("/usr/local/bin"));
  3. locations->push_back(base::FilePath("/usr/sbin"));
  4. locations->push_back(base::FilePath("/usr/bin"));
  5. locations->push_back(base::FilePath("/sbin"));
  6. locations->push_back(base::FilePath("/bin"));
  7. locations->push_back(base::FilePath("/opt/google/chrome")); // last try with the default installation location.

@johnchen, confirmed that, the binary search order on Linux was accidentally changed by r708243, which was intended to make it easier to configure the name of the Chrome binary, but accidentally changed the search order as well.

ChromeDriver team have updated ChromeDriver to fix this issue through this revision / commit.


Solution

The above mentioned solution is available with:


Interim solution

An interim solution would be using the binary_location attribute and you can find a detailed discussion in Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352