简体   繁体   English

将 Ec2 中的 Jenkins 与 Selenium 集成

[英]Integrating Jenkins in Ec2 with Selenium

I'm trying to integrate Jenkins with Selenium.我正在尝试将 Jenkins 与 Selenium 集成。 When I do the execution in Eclipse, Its opening an Firefox instance and test suite is working as expected.当我在 Eclipse 中执行时,它打开一个 Firefox 实例和测试套件按预期工作。

Below is my sample test file:下面是我的示例测试文件:

public class testFacebook {

    @Test
    public void TestFireFox(){


    WebDriver driver=new FirefoxDriver();

    driver.manage().window().maximize();

    driver.get("http://www.facebook.com");

    driver.quit();

    }

}

This is working good in windows 7 (eclipse build), as I have firefox installed in my system.这在 Windows 7(eclipse build)中运行良好,因为我的系统中安装了 Firefox。

But I need the same to be tested in Jenkins running on AWS ec2 instance (Linux AMI), When I create a build for the same above code in Jenkins, Below is the error I see.但是我需要在 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

I have installed Selenium plugin in Jenkins.我已经在 J​​enkins 中安装了 Selenium 插件。 Please let me what are the changes I have to do in Test file as well as things related to Firefox installation.请告诉我我必须在测试文件中做哪些更改以及与 Firefox 安装相关的事情。

Thanks in advance.提前致谢。

  1. add the path to the firefox binary to your path variable将 firefox 二进制文件的路径添加到您的路径变量中

or,或者,

  1. Do this: System.setProperty("webdriver.firefox.bin", "C:\\Users\\xxx\\AppData\\Local\\Mozilla Firefox\\firefox.exe");这样做: System.setProperty("webdriver.firefox.bin", "C:\\Users\\xxx\\AppData\\Local\\Mozilla Firefox\\firefox.exe");

    [ This example is for windows] [此示例适用于 Windows]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM