准备:TestNG、Selenium、Maven
1、在 pom.xml 文件中增加配置项。
##################
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
#################
2、@Test(invocationCount = N)
其中 N 是 TestNG 应该运行这个测试方法的次数。
实例一:repeatThis()方法将运行10次