2016-08-18 109 views
0

全部,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可能有問題,但無法進一步調試。

任何人都可以幫忙嗎? 非常感謝

志宏

回答

0

嗯,我有同樣的問題,我只是切換到Chrome網絡驅動器...

但是,如果你想留在Firefox嘗試升級硒3.0.0。

+0

感謝您的回答,不知道是否有一個硒3.0發佈,我會試一試,否則,將移動到鉻以及 – zhihong

+0

您可能也想使用壁虎驅動程序的Firefox 47 + https:// github.com/mozilla/geckodriver/releases/ – RadekE

+0

RadekE,謝謝,是的,我已經使用了壁虎驅動。不同的是,47 +和硒2.56,你修理木偶來解決問題。如果使用硒3.0(我試過你的建議),然後需要安裝壁虎驅動程序。 – zhihong

0

你已經做了一切正確的事。 昨天將Firefox升級到v48後,我今天遇到了同樣的問題。最好的解決方法是將降級到47.0.1(可從here下載),這是硒(2.35.1爲Java或2.35.0爲Python)

最好的運氣完全兼容!

+0

感謝您的回覆。我已經嘗試將firefox降級到47.0.1,得到了同樣的錯誤。和Bbad運氣,在將硒降級到2.35.0後,我得到了其他錯誤:WebDriverException:消息:'無法加載配置文件。 ...一個快速檢查,這與硒中的一箇舊bug有關。所以還沒有解決問題。 – zhihong

+0

該死,不吉利!困擾我的事情是根據你的帖子,這事情對你來說很好(例如v47.0.1火狐和Selenium 2.35.5) - 但你已經嘗試過了..確實你應該能夠恢復到舊的情況。新系統發生了什麼變化?只有事實可能是你的Firefox bin文件夾可能位於你的開發機器的其他地方,或者你沒有足夠的權限來訪問該文件夾..問題?您的舊設置在您的Ubuntu服務器上工作正常嗎?如果是的話,我認爲這更多的是指向正確的道路。 –

+0

在我的開發服務器中工作的硒是版本2.53.5。不是2.35.5。新的系統(並不是真正的新產品,而是一個生產服務器運行的腳本),與之前安裝的selenium和firefox不同,firefox bin的設置與我的開發相同,我可以看到的唯一區別是系統版本,新版本是14.04 .3,我的本地是14.04.05,我將更新服務器以查看會發生什麼 – zhihong