【发布时间】:2018-06-26 23:09:48
【问题描述】:
我在一个类中有两个测试用例。当使用 TestNg 并行运行时,它会连接所有测试数据并将其放在一个浏览器中,而另一个浏览器为空。
硒版本:3.8.21 火狐:最新 测试:6.8.21
package cli;
import java.net.MalformedURLException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class test1 {
public WebDriver driver;
@BeforeMethod
public void setUp() throws MalformedURLException {
System.out.println("@BeforeMethod: The annotated method will be run before each test method.");
}
@Test
public void test() throws MalformedURLException, InterruptedException {
driver = jenkinHub.hub();
driver.get("https://www.google.com/");
driver.findElement(By.xpath("//*[@id=\"lst-ib\"]")).sendKeys("Testing");
System.out.println("This is current Url " + driver.getCurrentUrl());
Thread.sleep(9000);
driver.quit();
}
@Test
public void NotTesting() throws MalformedURLException, InterruptedException {
driver = jenkinHub.hub();
driver.get("https://www.google.com/");
driver.findElement(By.xpath("//*[@id=\"lst-ib\"]")).sendKeys("Not Testing");
System.out.println("This is current Url " + driver.getCurrentUrl());
Thread.sleep(9000);
driver.quit();
}
}
xml文件
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Regression Suite" verbose="1" parallel="methods" thread-count="3">
<test name="REgressionSuite" group-by-instances="true">
<classes>
<class name="cli.test1" />
</classes>
</test>
</suite>
【问题讨论】: