selenium - Why does ChromeDriver 2.31 fail to start when run in Docker? -


i have docker container based on ubuntu:xenial. when try run selenium chrome webdriver loads endlessly

>>> selenium import webdriver >>> selenium.webdriver.chrome.options import options >>> chrome_options = options() >>> chrome_options.add_argument("--headless") >>> path_to_chromedriver = '/usr/local/bin/chromedriver' >>> browser = webdriver.chrome(path_to_chromedriver, chrome_options=chrome_options) traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__     desired_capabilities=desired_capabilities)   file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 140, in __init__     self.start_session(desired_capabilities, browser_profile)   file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 229, in start_session     response = self.execute(command.new_session, parameters)   file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 297, in execute     self.error_handler.check_response(response)   file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response     raise exception_class(message, screen, stacktrace) selenium.common.exceptions.webdriverexception: message: unknown error: chrome failed start: crashed   (driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=linux 4.10.0-32-generic x86_64) 

steps far

fix crash

>>> selenium import webdriver >>> browser = webdriver.chrome() traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__     self.service.start()   file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 96, in start     self.assert_process_still_running()   file "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 109, in assert_process_still_running     % (self.path, return_code) selenium.common.exceptions.webdriverexception: message: service chromedriver unexpectedly exited. status code was: 127 

when tried find version of chromedriver

chromedriver --version 

i got error shared library libnss3 not found. after installing libnss3, worked.

so line

run apt-get install libnss3 

should added dockerfile.

fix 'chrome binary not found'

install chrome. not enough install chromedriver_installer via pip.

run apt-get install wget run wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb run dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install 

you trying create custom images, when standard images available. should using selenium/chrome-standalone

docker run -d -p 4444:4444 selenium/standalone-chrom 

then in code launch remotewebdriver

from selenium import webdriver selenium.webdriver.common.desired_capabilities import desiredcapabilities driver = webdriver.remote(desired_capabilities=desiredcapabilities.chrome) 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -