我使用Robot Framework和Selenium2Library进行自动前端测试。通常我在Firefox浏览器中运行这些测试。从Firefox 47版开始,Selenium2Library的内置FirefoxDriver不再适用。通过互联网搜索了一下,发现,我必须切换到Marionette aka。 Gecko Driver。
尝试此操作时,我收到以下错误消息:
套件设置失败:WebDriverException:消息:指向的路径 驱动程序可执行文件必须由webdriver.gecko.driver系统设置 属性;有关更多信息,请参阅https://github.com/jgraham/wires。 最新版本可以从中下载 https://github.com/jgraham/wires
我再次尝试在Internet上找到设置GeckoDriver
可执行文件路径的方法,但我只找到了Java的方法。既不适用于Python也不适用于Robot Framework。有人知道如何在Python或Robot Framework
中设置系统属性吗?
答案 0 :(得分:2)
If you do not want to use Marionette, follow Mukesh's answer and change versions. If you want to use Marionette, the simplest approach is to add wires (or geckodriver in the future) to the system path as suggested by the Mozilla developers.
The Python bindings do not support setting the path to GeckoDriver other than by parameter to a webdriver __init__. So if modifying the system path is not an option, the only way forward is to pass the path to your executable into Selenium. From Robot Framework, you can do this with Create Webdriver. The __init__ for Firefox is documented here.
*** Settings ***
Library Selenium2Library
Library Collections
*** Test Cases ***
Specifying Path To GeckoDriver
${ff default caps} Evaluate sys.modules['selenium.webdriver'].common.desired_capabilities.DesiredCapabilities.FIREFOX sys,selenium.webdriver
Set To Dictionary ${ff default caps} marionette=${True}
Create Webdriver Firefox executable_path=C:\\stuff\\wires.exe
Go To https://stackoverflow.com
Sleep 2 s
[Teardown] Close All Browsers
答案 1 :(得分:0)
这是解决Firefox 47和Selenium2Library(导致您尝试使用Marionette / Gecko驱动程序)的兼容性问题的答案:
Firefox 47有一个错误导致它与selenium webdriver崩溃。此错误已在Firefox 47.0.1中修复(请参阅release notes)。
最新的Selenium2Library(或Selenium 2.53.6)和Firefox 47.0.1的组合应该可以正常工作。
希望这有帮助。