全部,firefox與硒不工作
最近,我設置了一個新的Ubuntu的服務器(版本14.04.3)的屏幕截圖解決方案與Firefox和硒。雖然自firefox v47以來有很多關於這個話題的討論,但似乎都無法解決我的問題。
我的python腳本是如下:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.FIREFOX
caps["marionette"] = True
caps["binary"] = "/usr/bin/firefox"
browser = webdriver.Firefox(capabilities=caps)
browser.set_window_size(1200, 2400)
對於我的發展服務器,我有火狐v47.0.1和硒2.53.5,和代碼工作。 但在我的新系統,在開始時,我的Firefox 48和硒2.53.6,我得到了錯誤:
browser = webdriver.Firefox(capabilities=caps)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 65, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
WebDriverException: Message: 'wires' executable needs to be in PATH.
我嘗試Firefox的二進制文件添加到PATH:
export PATH=$PATH:/usr/bin/firefox
在此之後,我得到了新的錯誤:
browser = webdriver.Firefox(capabilities=caps)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 65, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 20] Not a directory
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7fe3183edf50>> ignored
作爲後here提到V48應該可以解決這個問題,但現在看來,這是沒有的。然後我將firefox降級到v47.0.1,但仍然得到相同的錯誤。我檢查了v2.53.6和v2.53.5中的selenium代碼,無法真正確定問題。然後我卸載硒到v2.53.5。但仍然有同樣的錯誤。我認爲我的設置與硒有關的firefox可能有問題,但無法進一步調試。
任何人都可以幫忙嗎? 非常感謝
志宏
感謝您的回答,不知道是否有一個硒3.0發佈,我會試一試,否則,將移動到鉻以及 – zhihong
您可能也想使用壁虎驅動程序的Firefox 47 + https:// github.com/mozilla/geckodriver/releases/ – RadekE
RadekE,謝謝,是的,我已經使用了壁虎驅動。不同的是,47 +和硒2.56,你修理木偶來解決問題。如果使用硒3.0(我試過你的建議),然後需要安裝壁虎驅動程序。 – zhihong