【问题标题】:Unable to set the path to bin, lib for selenium (maven) project for jenkins无法为詹金斯的 selenium (maven) 项目设置 bin、lib 的路径
【发布时间】:2016-09-28 09:12:39
【问题描述】:

尝试运行 selenium 测试用例。我见过的哪个文件,建议是添加 bin 和 lib 目录的路径。

Set projectLocation=F:\Selenium\TestNGBatchExample
cd %projectLocation%
set classpath=%projectLocation%\bin;%projectLocation%\lib\*
java org.testng.TestNG %projectLocation%\testng.xml
pause

但是在 maven 项目中,我的 maven 项目中没有 bin、lib 文件夹。导出投影或任何其他地方是否有任何错误。从 eclipse 执行时,测试用例在本地环境中完美运行。

<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>automationtests360</groupId>
	<artifactId>s360test</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>page factory in simplify360</name>
	<description>page factory in simplify360</description>
	<dependencies>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-java</artifactId>
			<version>3.0.0-beta2</version>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-firefox-driver</artifactId>
			<version>3.0.0-beta2</version>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-chrome-driver</artifactId>
			<version>3.0.0-beta2</version>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-server</artifactId>
			<version>3.0.0-beta2</version>
		</dependency>
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-htmlunit-driver</artifactId>
			<version>2.52.0</version>
		</dependency>
		<dependency>
			<groupId>org.testng</groupId>
			<artifactId>testng</artifactId>
			<version>6.9.10</version>
		</dependency>
		<dependency>
			<groupId>javax.activation</groupId>
			<artifactId>activation</artifactId>
			<version>1.1.1</version>
		</dependency>
		<dependency>
			<groupId>org.mongodb</groupId>
			<artifactId>mongo-java-driver</artifactId>
			<version>2.11.3</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.jackson</groupId>
			<artifactId>jackson-mapper-asl</artifactId>
			<version>1.9.13</version>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.17</version>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.36</version>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.3</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.19.1</version>
				<configuration>
					<suiteXmlFiles>
						<suiteXmlFile>testng.xml</suiteXmlFile>
					</suiteXmlFiles>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

【问题讨论】:

  • 您在pom.xml 中添加了什么来执行项目?
  • Testng 是用于执行测试用例的框架。如果我提供的信息不正确,请解释我应该在 pom.xml 中查看哪些信息

标签: selenium jenkins


【解决方案1】:

要通过 Maven 执行 testNg.xml 文件,您可以使用 surefire 插件。在pom.xml 文件的plugins > configuration 部分添加以下行,如果您还没有的话。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
        </suiteXmlFiles>
    </configuration>
</plugin>

【讨论】:

  • 在尝试构建时出现此错误 [错误] 无法在项目 s360test 上执行目标 org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test):目标 org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed 的执行 default-test: There was an error in the forked process [ERROR] org.apache.maven.surefire.testset.TestSetFailedException:套件文件 D:\TestAutomation\s360Selenium_1\testng.xml 不是有效文件
  • 添加了 pom.xml 文件
  • 它说您提供的testing.xml 文件不是有效文件。该文件是否在给定位置可用?请把文件贴在这里好吗?
  • 不,我的项目中没有这样的文件。您给出的代码中的 testng.xml 文件是什么。即使我尝试添加生成的测试用例 xml 来执行 xml 文件,但仍然是同样的问题
  • 哦..如果您通过TestNG执行它,您需要指定一个有效文件名的名称。
猜你喜欢
  • 1970-01-01
  • 2019-05-03
  • 2017-12-08
  • 1970-01-01
  • 1970-01-01
  • 2012-11-29
  • 1970-01-01
  • 2020-01-12
  • 1970-01-01
相关资源
最近更新 更多