我将 Robot Framework 与 Selenium2Library 一起使用来进行自动化前端测试。通常我在 Firefox 浏览器中运行这些测试。从 Firefox 47 版本开始,Selenium2Library 的内置 FirefoxDriver 不再工作。 A 在互联网上搜索了一下,发现我必须切换到 Marionette aka。壁虎驱动程序。
尝试此操作时,我收到以下错误消息:
Suite setup failed: WebDriverException: Message: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/jgraham/wires. The latest version can be downloaded from https://github.com/jgraham/wires
我再次尝试在互联网上寻找一种设置GeckoDriver
可执行文件路径的方法,但我只找到了一种适用于Java的方法。既不适用于 Python,也不适用于机器人框架。有人知道如何在 Python 或 Robot Framework
中设置系统属性吗?
最佳答案
如果您不想使用 Marionette,请按照 Mukesh 的回答并更改版本。 如果您想使用 Marionette,最简单的方法是将线(或将来的 geckodriver)添加到系统路径,如建议 by the Mozilla developers .
Python 绑定(bind)不支持设置 GeckoDriver 的路径,除非通过 Webdriver __init__ 的参数。因此,如果无法修改系统路径,唯一的方法是将可执行文件的路径传递到 Selenium 中。在 Robot Framework 中,您可以使用 Create Webdriver 来执行此操作。 Firefox 的 __init__ 记录在 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
关于python - 如何使用Robot Framework设置系统属性 "webdriver.gecko.driver"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38307054/