我试图将Jenkins与Selenium整合在一起。 当我在Eclipse中执行时,它打开一个Firefox实例和测试套件正在按预期工作。
以下是我的示例测试文件:
public class testFacebook {
@Test
public void TestFireFox(){
WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.facebook.com");
driver.quit();
}
}
这在Windows 7(eclipse构建)中运行良好,因为我在我的系统中安装了firefox。
但我需要在运行AWS ec2实例(Linux AMI)的Jenkins中进行测试,当我在Jenkins中为相同的上述代码创建构建时,下面是我看到的错误。
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.52 sec <<< FAILURE! - in TestSuite
TestFireFox(com.selenium.SeleniumTesting) Time elapsed: 0.141 sec <<< FAILURE!
org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
Build info: version: '2.47.1', revision: 'unknown', time: '2015-07-30 11:02:44'
System info: host: 'ip-172-31-18-42', ip: '172.31.18.42', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.35-33.55.amzn1.x86_64', java.version: '1.8.0_112'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:74)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
at com.selenium.SeleniumTesting.TestFireFox(SeleniumTesting.java:12)
Results :
Failed tests:
SeleniumTesting.TestFireFox:12 » WebDriver Cannot find firefox binary in PATH....
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
我在Jenkins中安装了Selenium插件。请告诉我在测试文件中我需要做的更改以及与Firefox安装相关的事情。
提前致谢。
答案 0 :(得分:0)
或者,
这样做: System.setProperty("webdriver.firefox.bin", "C:\Users\xxx\AppData\Local\Mozilla Firefox\firefox.exe");
[此示例适用于 Windows]