I am trying to use headless chrome
with selenium
, I created a symlink for path to chromedriver into /usr/local/bin, but when I run
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
browser = webdriver.Chrome()
browser.get('http://www.google.com')
I got the error as
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/anaconda2/envs/tensorflow/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "/opt/anaconda2/envs/tensorflow/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/opt/anaconda2/envs/tensorflow/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/opt/anaconda2/envs/tensorflow/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/opt/anaconda2/envs/tensorflow/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.10.0-327.22.2.el7.x86_64 x86_64)
Also it generates a core.*****, a core file dot with five random numbers, which is more than 200MB large.
Versions:
Selenium 3.0.0b3
Google Chrome 60.0.3112.113
chromedriver 2.30
Could anyone help me figure out what is wrong please?
As you are trying to open Chrome browser in headless mode, you don't need to create any extra settings or symlink. Save/Store the
chromedriver
anywhere on your system and access the location by its absolute path. To include the argument--headless
you need to take help ofOptions
class and pass the object while initializing thewebdriver
object as below:Console Output: