I am using ITestListener, Extent Manager for Generating Extent Report. It is working fine. I'm calling 5 @Test methods from another method. The Reports (TestNG & Extent Report) usually showing only 1 output for the executed test. Please suggest any other way to get the @Test Output when they called from another method. I want to control execution of my methods through from excel instead of creating long XML files.
Please Check my sample Code: Suggest any other way to acheive the Report
My TestNG XML file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="logixexpress" parallel="false">
<listeners>
<listener class-name="common.CommonITestNGListener"></listener>
</listeners>
<parameter name = "Browser" value = "Chrome"></parameter>
<parameter name = "DataFile" value = "\\TestData\\Express.xlsx"></parameter>
<parameter name = "AppRepoFile" value = "\\OR\\AppRepo.properties"></parameter>
<test name="Express Test Execution">
<classes>
<class name="logixexpress.Driver">
</class>
</classes>
</test>
</suite>
My Driver Script:
public class Driver extends commonhelper{
public static int Drvrownum = 3;
@Test
public void ExecuteDriver() throws Exception {
for (int i = Drvrownum; i < (ExcelWS.getLastRowNum() + Drvrownum); i++) {
String mname = GetDatafromCell("Global", Drvrownum, "ActionName");
String EF = GetDatafromCell("Global", Drvrownum, "ExecutionFlag");
if (EF.equalsIgnoreCase("false")) {
Drvrownum = Drvrownum + 1;
continue;
}
else {
switch (mname) {
case "WorkQueue":
WorkQueue wq = new WorkQueue();
wq.RunWQcases();
Drvrownum = Drvrownum + 1;
break;
case "XXX":
System.out.println("All Iterations Completed");
Drvrownum = Drvrownum + 1;
return;
default:
break;
}
}
}
}
}
And my test Script:
public class WorkQueue extends commonhelper{
public static int WQrownum = 2;
public static String EXLFilePath = scrpath + "\\TestData\\Express.xlsx";
@Test
public void RunWQcases() throws Exception {
setExcelFile(EXLFilePath, "WorkQueue");
for (int i = WQrownum; i < (ExcelWS.getLastRowNum() + WQrownum); i++) {
String WQMname = GetDatafromCell(WQrownum, "ActionName");
String AEF = GetDatafromCell(WQrownum, "ExecutionFlag");
if (AEF.equalsIgnoreCase("false")) {
WQrownum = WQrownum + 1;
continue;
}
else {
switch (WQMname) {
case "ExecuteWQ":
ExecuteWQ();
WQrownum = WQrownum + 1;
break;
case "openchart":
openchart();
WQrownum = WQrownum + 1;
break;
case "XXX":
System.out.println("Sub Class Iterations Completed");
WQrownum = WQrownum + 1;
return;
}
}
}
}
@Test
public void ExecuteWQ() throws Exception {
driver.findElement(By.linkText("Work Queue")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Coding WQ")));
driver.findElement(By.linkText("Coding WQ")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//table[@class='main']")));
}
@Test
public void openchart() throws Exception {
WebElement wqtable = driver.findElement(By.xpath("//table[@class='main']"));
List<WebElement> trow = wqtable.findElements(By.tagName("tr"));
for (int i = 0; i < trow.size(); i++) {
boolean getrow = false;
List<WebElement> tcol = trow.get(i).findElements(By.tagName("th"));
System.out.println("Number of Columns = " + tcol.size());
for (int j = 0; j < tcol.size(); j++) {
if (tcol.get(j).getText().equalsIgnoreCase("Action")) {
driver.findElement(By.className("grid-edit")).click();
getrow = true;
break;
}
}
if (getrow) {
break;
}
}
Thread.sleep(2000);
}
}