【发布时间】:2018-07-17 13:04:42
【问题描述】:
我正在尝试在 Jenkins 上运行我的测试(Selenium+junit+cucumber+Maven)。 在我的定义类中,我没有指向 Chrome 二进制文件,而是使用 WebDriverManager:
@Given("^我导航到页面$")
public void i_navigate_to_webpage() throws Throwable {
String url = Helper.getPropValue("landing", "navigation");
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
wait = new WebDriverWait(driver,20);
driver.manage().window().maximize();
driver.get(url);
}
它在我的机器(Win)上运行良好,但是当我试图在 Jenkins(Ubuntu 机器)上执行它时,我得到了错误:
org.openqa.selenium.WebDriverException:未知错误:找不到 Chrome 二进制文件 (驱动程序信息:chromedriver=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.4.0-1047-aws x86_64)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:687 毫秒 构建信息:版本:'2.48.2',修订:'41bccdd10cf2c0560f637404c2d96164b67d9d67',时间:'2015-10-09 13:08:06' 系统信息:主机:'ip-172-31-12-150',ip:'172.31.12.150',os.name:'Linux',os.arch:'amd64',os.version:'4.4.0- 1047-aws',java.version:'1.8.0_151' 驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor.java:423) 在 org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 在 org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647) 在 org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129) 在 org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142) 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:170) 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:159) 在 org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:116) 在 GridTest.grid.StepDef.i_navigate_to_webpage(StepDef.java:52) 在✽。鉴于我导航到页面(src/test/test.feature:6)
我的印象是 WebDriverManager 应该已经涵盖了它在我的 Windows 机器上的作用。不是吗?
我的 Pom.xml 文件在这里:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>GridTest</groupId>
<artifactId>grid</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>grid</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<suiteXmlFile>testing.xml</suiteXmlFile>
</properties>
<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.lazerycode.selenium
</groupId>
<artifactId>
driver-binary-downloader-maven-plugin
</artifactId>
<versionRange>
[1.0.17,)
</versionRange>
<goals>
<goal>selenium</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.48.2</version>
</dependency>
</dependencies>
</project>
【问题讨论】:
标签: java maven google-chrome selenium