2016-06-13 133 views
4

我想在遠程服務器上運行selenium webdriver。我只是想一個非常簡單的腳本:在ssh中運行Python Selenium webdriver

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() 

的錯誤是:

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 

我不知道什麼是錯的我的設置,以及如何來解決這個問題。 謝謝!

回答

0

如果你改變Chrome瀏覽器的Firefox瀏覽器,它可以正常工作(只要你有正確的Firefox版本 - 硒總是趕上,但它有一些延遲 - 所以可能需要更舊的版本(更新硒並檢查版本

至於Chrome,請嘗試在參數中給出路徑。例如:driver = webdriver.Chrome('PATH\TO\CHROME')

相關問題