Jenkins上的Selenium和chrome驱动程序:与localhost的连接被拒绝

时间:2016-12-09 09:42:40

标签: java selenium jenkins automated-tests selenium-chromedriver

我在Jenkins 2.35上使用Selenium 3.0.1和Xvfb上的Chrome驱动程序2.25在Ubuntu服务器上运行作业。 Chrome版本55.0.2883.75。 驱动程序无法初始化,并显示以下错误:

  

initializeDriver(com.myproject.invoicestests.InvoicesTests)经过的时间:13.128秒<<<失败!   org.openqa.selenium.WebDriverException:   org.apache.http.conn.HttpHostConnectException:连接到localhost:1904 [localhost / 127.0.0.1,localhost / 0:0:0:0:0:0:0:1]失败:连接被拒绝   构建信息:版本:' 3.0.1',修订版:' 1969d75',时间:' 2016-10-18 09:49:13 -0700'   系统信息:主持人:' test.test.com',ip:' 127.0.0.1',os.name:' Linux',os.arch:& #39; amd64',os.version:' 3.13.0-103-generic',java.version:' 1.8.0_92'   驱动程序信息:driver.version:ChromeDriver

在驱动程序初始化之下:

public static WebDriver initChromeDriver() {

    WebDriver driver;

    String chromePath;

    if (OS.contains("Windows"))
        chromePath = "/var/lib/jenkins/drivers/chromedriver.exe";
    else
        chromePath = "/var/lib/jenkins/drivers/chromedriver";

    Map map = new HashMap();
    map.put("DISPLAY",":1");

    final ChromeDriverService service = new ChromeDriverService.Builder().usingAnyFreePort()
            .usingDriverExecutable(new File(chromePath))
            .withSilent(true)
            .withEnvironment(map)
            .build();
    try {
        service.start();
    } catch (IOException e) {
        e.printStackTrace();
    }
    driver = new ChromeDriver(service);
    driver.manage().window().maximize();

    return driver;
}

非常感谢任何帮助。 谢谢!

0 个答案:

没有答案