全,
最近,我设置了一个新的ubuntu服务器(版本14.04.3),用于firefox和selenium的屏幕截图解决方案。虽然自火狐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)对于我的开发服务器,我使用的是Firefoxv47.0.1和selenium 2.53.5,代码可以正常工作。但在我的新系统中,一开始,我使用的是firefox 48和selenium 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二进制文件添加到路径中:
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代码,无法真正识别问题。然后我将selenium卸载到v2.53.5。但是仍然会得到相同的错误。我认为我的设置可能与使用selenium的firefox相关,但无法进一步调试。
有人能帮上忙吗?非常感谢
志宏
发布于 2016-08-18 22:27:53
嗯,我有同样的问题,我只是切换到Chrome web driver……
但是,如果您想继续使用Firefox,请尝试将selenium升级到3.0.0。
发布于 2016-08-18 22:33:28
你做的每件事都是正确的,志宏。我昨天把火狐升级到v48后,今天也遇到了同样的问题。最好的解决方案是降级回47.0.1 (可以从here下载),它完全兼容Selenium ( 2.35.1 for Java或2.35.0 for Python)
祝你好运!
https://stackoverflow.com/questions/39020419
复制相似问题