gpt4 book ai didi

java - 在 Selenium 3 中启动 Firefox ThreadLocal 驱动程序 - Java

转载 作者:行者123 更新时间:2023-11-29 04:40:03 24 4
gpt4 key购买 nike

我刚刚更新到 Selenium 3.0.0-beta3 并尝试在 Firefox 45 中执行测试。

我已经下载了 geckodriver.exe v.10 并将其添加到我的 PATH 环境变量中。我还在 geckodriver 的代码中设置系统属性,就像我在使用 Chrome 驱动程序时所做的那样,它工作得很好,但是,我仍然得到以下 TestNG 消息:

org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases Command duration or timeout: 411 milliseconds Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43' System info: host: 'VMP-2316', ip: '10.80.50.100', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_92' Driver info: org.openqa.selenium.remote.RemoteWebDriver

这是我用来设置驱动程序的代码:

// Set Driver
threadDriver = new ThreadLocal<RemoteWebDriver>();
DesiredCapabilities dc = new DesiredCapabilities();

System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");

dc.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
dc.setCapability("marionette", true);

threadDriver.set(new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc));

最佳答案

另一种方法是在启动服务器/节点的命令行中定义驱动程序的路径:

java -Dwebdriver.gecko.driver=path/to/geckodriver.exe -jar selenium-server-standalone-3.0.0-beta3.jar

关于java - 在 Selenium 3 中启动 Firefox ThreadLocal 驱动程序 - Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39574349/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com