我正在尝试通过testng.xml
文件运行2个类。总共需要运行5到6种方法。但是,当我使用testng.xml
执行时,总共只有3个测试正在运行。但是当我运行单个类时,它运行得很好。
类:SmartRetrievePageTest.java
package tests;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import base.BrowserFactory;
import helper.DriverOperations;
import pages.HomePage;
import pages.LoginPage;
import pages.SmartRetrievePage;
import testbase.TestBase;
public class SmartRetrievePageTest extends TestBase {
LoginPage loginPage;
HomePage homePage;
SmartRetrievePage smartretrievePage;
public SmartRetrievePageTest()
{
super();
}
@BeforeMethod(groups = { "SmartRetrieve" })
public void setUp() throws Exception {
BrowserFactory.launchApplication(prop.getProperty("Browser"), prop.getProperty("URL"));
loginPage = new LoginPage();
smartretrievePage = new SmartRetrievePage();
homePage = loginPage.login(prop.getProperty("UserName"),prop.getProperty("Password"));
Thread.sleep(2000);
//smartDepositPage = homePage.clickDepositLink();
DriverOperations.expandTopNavigationMenuAndPerformNavitation("Select application", "SmartRetrieve");
Thread.sleep(3000);
}
@Test(priority = 1, groups = { "SmartRetrieve" })
public void QuickSearch() throws Throwable {
smartretrievePage.QuickSearching(prop.getProperty("QuickSearchKeyword"));
//smartretrievePae.QuickSearching("adm");
Thread.sleep(3000);
}
@Test(priority = 2, groups = { "SmartRetrieve" }, alwaysRun=true)
public void AdvSearch() throws Throwable {
smartretrievePage.AdvanceSearching(prop.getProperty("AdvanceSearchkeyword"));
Thread.sleep(3000);
}
@Test(priority = 3, groups = { "SmartRetrieve" }, alwaysRun=true)
public void SimpleSaveSearch() throws Throwable {
smartretrievePage.sipmleSaveSearch(prop.getProperty("AdvanceSearchkeyword"),prop.getProperty("SearchName"));
Thread.sleep(3000);
}
@AfterMethod(groups = { "SmartRetrieve" })
public void tearDown() throws Exception{
DriverOperations.logOut();
}
}
类:SmartRetrievePage.java
package pages;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import base.BrowserFactory;
import helper.DriverOperations;
public class SmartRetrievePage extends BrowserFactory{
//here are findElemtnts
public SmartRetrievePage()
{
PageFactory.initElements(driver, this);
}
public void QuickSearching(String keyword) throws InterruptedException
{
DriverOperations.clearFieldAndEnterStringData(quickSearch, keyword);
DriverOperations.clickWhenElementIsClickable(ShowResultQuickSearch);
Thread.sleep(3000);
//return new SmartRetrievePage();
}
public void AdvanceSearching(String SearchValue) throws InterruptedException
{
DriverOperations.selectDropdownOptionByVisibleText(RetrieveDocumentType, "inv_header");
DriverOperations.clearFieldAndEnterStringData(Searchvalue, SearchValue);
DriverOperations.clickWhenElementIsClickable(ShowResult);
Thread.sleep(3000);
}
public void sipmleSaveSearch(String SearchValue, String searchName) throws InterruptedException
{
DriverOperations.selectDropdownOptionByVisibleText(RetrieveDocumentType, "inv_header");
DriverOperations.clearFieldAndEnterStringData(Searchvalue, SearchValue);
DriverOperations.clickWhenElementIsClickable(SaveSearchButton);
DriverOperations.clearFieldAndEnterStringData(SearchName, searchName);
DriverOperations.clickWhenElementIsClickable(SaveSearch);
Thread.sleep(3000);
}
}
以相同的方式存在SmartRetentionPageTest.java
和SmartRetentionPage.java
类。以下是testng.xml
文件。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Smoke testSuite" >
<test name="Smoke test" >
<groups>
<run>
<include name="SmartRetrieve" />
<include name="SmartRetention" />
</run>
</groups>
<classes>
<class name="tests.SmartRetrievePageTest" />
<class name="tests.SmartRetentionPageTest" />
</classes>
</test>
</suite>
答案 0 :(得分:0)
这里有同样的问题,但是我这样解决了:
我已将TestNG套件分为以下两个测试
<test name="Smoke test1" >
<groups>
<run>
<include name="SmartRetrieve" />
</run>
</groups>
<classes>
<class name="tests.SmartRetrievePageTest" />
</classes>
</test>
<test name="Smoke test2" >
<groups>
<run>
<include name="SmartRetention" />
</run>
</groups>
<classes>
<class name="tests.SmartRetentionPageTest" />
</classes>
</test>
</suite>