seleniumTestNG中XML中Class中有多个@Test,Class文件单独执行所有@Test执行成功,xml中只有一@Test执行
创建测class文件如下packagetestCases;publicclassAddBAMasterList{publicWebDriverdriver;StringB...
创建测class文件如下
package testCases;
public class AddBAMasterList {
public WebDriver driver;
String BAName=PublicModule.getCurrentTime();
private BAPage baPage;
@Test(priority=1)
public void AddBA() throws InterruptedException {
LoginPage loginPage=new LoginPage(driver);
loginPage.login();
Thread.sleep(3000);
baPage=new BAPage(driver);
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.findElement(By.id("DashBoard")).getText().contains("Dashboard");
}
});
Boolean flagBA=baPage.NewBAMasterList(BAName);
Assert.assertTrue(flagBA);
Reporter.log("Add Master List for BA Successfully");
}
@Test(priority=2)
public void AddRepeatedBA() throws InterruptedException {
Boolean flagReBA=baPage.NewRepeatBAMasterList(BAName);
Assert.assertTrue(flagReBA);
Reporter.log("Add Repeated Master List for BA is not allowed");
}
@BeforeClass
public void beforeClass() {
//System.setProperty("webdriver.gecko.driver", "D:\\AAA\\geckodriver-v0.20.1-win64\\geckodriver.exe");
System.setProperty("webdriver.chrome.driver", "D:\\3\\chromedriver_win32\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}
Testng.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestAll">
<test name="case1">
<classes>
<class name="testCases.LoginSmart"/>
<class name="testCases.MLOperation"/>
<class name="testCases.AddSMMasterList"/>
<class name="testCases.AddBAMasterList"/>
</classes>
</test>
</suite>
xml配置有4个类文件,如果只配置AddBAMasterList类文件.该类文件中的两个@Test都能执行,配置4个类文件就只有第一个@Test执行,求大神解答 展开
package testCases;
public class AddBAMasterList {
public WebDriver driver;
String BAName=PublicModule.getCurrentTime();
private BAPage baPage;
@Test(priority=1)
public void AddBA() throws InterruptedException {
LoginPage loginPage=new LoginPage(driver);
loginPage.login();
Thread.sleep(3000);
baPage=new BAPage(driver);
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.findElement(By.id("DashBoard")).getText().contains("Dashboard");
}
});
Boolean flagBA=baPage.NewBAMasterList(BAName);
Assert.assertTrue(flagBA);
Reporter.log("Add Master List for BA Successfully");
}
@Test(priority=2)
public void AddRepeatedBA() throws InterruptedException {
Boolean flagReBA=baPage.NewRepeatBAMasterList(BAName);
Assert.assertTrue(flagReBA);
Reporter.log("Add Repeated Master List for BA is not allowed");
}
@BeforeClass
public void beforeClass() {
//System.setProperty("webdriver.gecko.driver", "D:\\AAA\\geckodriver-v0.20.1-win64\\geckodriver.exe");
System.setProperty("webdriver.chrome.driver", "D:\\3\\chromedriver_win32\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
@AfterClass
public void afterClass() {
driver.quit();
}
}
Testng.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestAll">
<test name="case1">
<classes>
<class name="testCases.LoginSmart"/>
<class name="testCases.MLOperation"/>
<class name="testCases.AddSMMasterList"/>
<class name="testCases.AddBAMasterList"/>
</classes>
</test>
</suite>
xml配置有4个类文件,如果只配置AddBAMasterList类文件.该类文件中的两个@Test都能执行,配置4个类文件就只有第一个@Test执行,求大神解答 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询