本来是想选择selenium+python的,但是因为对python不是很熟悉,于是还是选择了java,以后肯定还是要研究一下python的。
首先先安装java的环境,配置jdk之类的就不说了,这里我用了一个新的工具IDEA,原来我都是用eclipse的。
在IDEA里新建一个maven项目
如图:
创建好了maven项目之后就要导入selenium包了,这里我们使用dependency导入,把如下的代码复制添加到的pom里就可以了。
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.30</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<inherited>true</inherited>
<!-- <configuration> <suiteXmlFile>testng.xml</suiteXmlFile> </configuration> -->
</plugin>
</plugins>
</build>
这样,selenium就安装好了,包也导进去了,这里安装的是2.53.1版本的selenium。