在Firefox上执行selenise runner

时间:2017-01-17 05:18:46

标签: firefox selenium-webdriver selenium-ide selenium-firefoxdriver geckodriver

我正在使用selenise runner在不同的浏览器中运行脚本。

我正在使用此配置文件:

firefox: C://Users/Desktop/geckodriver.exe
highlight: Yes
baseurl: https://example.com/
set-speed: 1000
timeout: 30000
driver: firefox
xml-result: C://Users/Desktop/Selenise/XMLReport
html-result: C://Users/Desktop/Selenise/HTMLReport

和此命令执行执行jar和报告:

set webdriver.gecko.driver=C:\Users\Desktop\geckodriver.exe
set path=%path%;webdriver.gecko.driver;
java -jar cmdJars.jar TestCases\TestCase1.html --config config.txt --driver firefox --firefox "C://Program Files/Mozilla Firefox/firefox.exe"

我收到此错误日志:

[2017-01-17 10:34:38.139 +05:30] [INFO] Start: Selenese Runner 3.0.0
[2017-01-17 10:34:38.357 +05:30] [INFO] Firefox binary: C://Program Files/Mozill
a Firefox/firefox.exe
java.lang.IllegalStateException: The path to the driver executable must be set b
y 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
        at com.google.common.base.Preconditions.checkState(Preconditions.java:19
9)
        at org.openqa.selenium.remote.service.DriverService.findExecutable(Drive
rService.java:109)
        at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriver
Service.java:37)
        at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExe
cutable(GeckoDriverService.java:95)
        at org.openqa.selenium.remote.service.DriverService$Builder.build(Driver
Service.java:296)
        at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(Firef
oxDriver.java:277)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:2
47)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:2
42)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:1
35)
        at jp.vmi.selenium.webdriver.FirefoxDriverFactory.newInstance(FirefoxDri
verFactory.java:173)
        at jp.vmi.selenium.webdriver.WebDriverManager$Builder.build(WebDriverMan
ager.java:77)
        at jp.vmi.selenium.webdriver.WebDriverManager.get(WebDriverManager.java:
266)
        at jp.vmi.selenium.selenese.Main.setupRunner(Main.java:139)
        at jp.vmi.selenium.selenese.Main.run(Main.java:82)
        at jp.vmi.selenium.selenese.Main.main(Main.java:221)
[2017-01-17 10:34:38.434 +05:30] [INFO] Exit code: 1

我也在系统环境变量中设置了webdriver.gecko.driver

为什么即使在设置了gecko驱动程序的路径后我也会收到此错误。

版本: 壁虎司机:geckodriver 0.13.0, Selenise亚军:Selenese Runner 3.0.0

1 个答案:

答案 0 :(得分:0)

您确定webdriver.gecko.driver系统属性已设置吗?

你可以将它作为JVM参数传递(我不得不在Mac上,因为它不像环境变量中的点那样):

java -Dwebdriver.gecko.driver=/path/to/geckodriver -jar cmdJars.jar TestCases\TestCase1.html --config config.txt --driver firefox --firefox "C://Program Files/Mozilla Firefox/firefox.exe"

请确保-D出现在-jar之前,如上所述。