转发:作者:adien_cui (灵枢),发表于 TesterHome:https://testerhome.com/topics/9606,
首先创建一个Maven项目
1、打开eclipse,选择File-new-Other
2、选择Maven Project,点击“next”
3、直接点击“next”
4、在Catalog下拉选项中选择Internal,然后选择maven模板:maven-archetype-quickstart,再点击“next”
5、在Group Id文本框输入公司域名,Artifact Id文本框输入项目名称,点击“Finish”
6、创建好的项目如下图:
7、编辑pom.xml,添加tesng、selenium依赖,添加maven-surefire-plugin插件,如下:
<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>com.zwy</groupId>
<artifactId>AutoTestDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AutoTestDemo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
</dependencies>
<build>
<defaultGoal>compile</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source