Selenium安装木偶webdri

2024-05-16 06:04:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我对火狐47版有这个问题https://github.com/seleniumhq/selenium/issues/2110

所以,我试图添加木偶网络驱动程序来修复它:https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver

但是:

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/Users/myproject/geckodriver-0.8.0-OSX'

返回错误:

selenium.common.exceptions.WebDriverException: Message: 'wires' executable needs to be in PATH.

Exception AttributeError: "'Service' object has no attribute 'process'" in > ignored

硒=2.53.5


Tags: inhttps网络githubcomselenium驱动程序common
3条回答

我可以确认ran into this issue应该指向Firefox二进制文件,而不是GeckoDriver。关于这个主题,Mozilla WebDriver documentation中的Python示例已经阐明。

除了其他两个答案之外,您可能不想更改系统范围内的PATH,因为您只在运行测试时需要它。只有在需要时才有权使用PATH的方法是在代码中设置它:

os.environ["PATH"] += os.pathsep + 'path/to/dir/containing/geckodriver/'

一个更简单的解决方法是简单地将geckodriver二进制文件移动到路径中已有的目录:

mv geckodriver /usr/local/bin

您设置的firefox二进制功能指向的是firefox二进制文件,而不是木偶驱动程序二进制文件。您需要将/Users/myproject/geckodriver-0.8.0-OSX添加到路径中,如下所示:

打开终端并运行此命令

export PATH=$PATH:/Users/myproject/geckodriver-0.8.0-OSX

相关问题 更多 >