5

I want to run selenium webdriver in a remote server. I just tried a really simple script:

from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800,600))
display.start()
driver = webdriver.Chrome()
driver.get("http://www.google.com")
print browser.title
browser.quit()
display.stop()

The error is:

File "1.py", line 7, in <module>
driver = webdriver.Chrome()
File "/home/shunyang/.local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 61, in __init__
self.service.start()
File "/home/shunyang/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 85, in start
self.assert_process_still_running()
File "/home/shunyang/.local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 98, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException:
Message: Service chromedriver unexpectedly exited. 
Status code was: 1 

I wonder what is wrong with my setup and how to solve this issue. Thanks!

2 Answers 2

1

I had the same problem. After trying many things, updating chrome solved it :)

sudo apt-get install google-chrome-stable
Sign up to request clarification or add additional context in comments.

3 Comments

Check your version with google-chrome --version and download the chromedriver for the version you have.
If I run the script from the terminal (connected to Ubuntu via VNC Viewer), it works. But if I run the script via PuTTy (SSH connection from Windows), it fails (Chrome doesn't start correctly).
What are your chromedriver configurations? Have you set headless? chrome_options = Options() chrome_options.add_argument("--headless") driver = webdriver.Chrome(chrome_options=chrome_options)
0

If you change Chrome for Firefox, it works just fine (as long as you have correct version of Firefox - selenium always catches up, but it has some delay - so older version might be needed (update selenium and check what version works with it).

As for Chrome, try giving it path in argument. For example: driver = webdriver.Chrome('PATH\TO\CHROME').

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.