无法在TC(Linux)中运行Selenium测试,但是对于Windows中的本地计算机来说可以

时间:2019-06-28 07:10:25

标签: java selenium automation teamcity gradlew

使用命令./gradlew clean runTests

运行时,出现以下错误
  

在Windows上本地:OKI   在Linux中的TeamCity上:.driverSetUp FAILED                         java.lang.IllegalStateException

     

INFO [newLocalDriver] INFO创建带有选项的驱动程序   ro.automation.canalLaDistanta.Achizitie_DeviceSTD.driverSetUp失败

这是我的代码。

public WebDriver newLocalDriver() {

    System.setProperty("webdriver.chrome.driver", getChromeDriverPath());

    ChromeOptions options = new ChromeOptions();
    options.setBinary(getChromeBinaryPath());

    options.addArguments("--no-default-browser-check");
    options.addArguments("window-size=1280,960");
    options.setHeadless(false);
    options.addArguments("start-maximized");

    log4j.info("Creating driver with options");
    ChromeDriver localChromeDriver = new ChromeDriver(options);
    log4j.info("Driver created: " + localChromeDriver);
    return localChromeDriver;
} 

private String getChromeDriverPath() {

    String chromeDriverPath = null;
    System.out.println(operatingSystem);

    if (operatingSystem.contains("windows")) {
    chromeDriverPath = "resources/browser/chromeDriver-windows/chromedriver.exe";
        System.out.println("+++ Windows ChromeDriver found! +++");
    } else if (operatingSystem.contains("linux")) {
        chromeDriverPath = "resources/browser/chromeDriver-linux/chromedriver";
        System.out.println("+++ Linux ChromeDriver found! +++");
    } else System.out.println("OS does not match with Windows or Linux");

    return chromeDriverPath;

0 个答案:

没有答案