我面临将子测试添加到父级的问题。
我的要求是:当我点击' +'时,我想要一个带有展开(' +')图标的父标签(例如登录)图标,我应该能够进行所有登录测试(这将是添加到登录标签的子测试
代码:
package Rapport;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
import test1.TimeReport;
@Listeners(TimeReport.class)
public class Test001 {
private ExtentReports reporter = SimpleReportFactory.getReporter();
ExtentTest testReporter ;
//ExtentReports extent;
ExtentTest parent;
public void TearDown()
{
parent.appendChild(testReporter);
}
public Test001()
{
parent = reporter.startTest("Test001");
}
@Test
public void simpleTest004()
{
testReporter = reporter.startTest("simpleTest004", "This is a simple simpleTest004");
testReporter.log(LogStatus.INFO, "Starting test simpleTest004");
int a = 100;
int b = 30;
testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
Assert.assertTrue(true);
// testReporter.log(LogStatus.FA, "Loading the value of b to " + b);
reporter.endTest(testReporter);
}
@Test
public void simpleTest003()
{
testReporter = reporter.startTest("simpleTest003", "This is a simple simpleTest003");
testReporter.log(LogStatus.INFO, "Starting test simpleTest003");
int a = 100;
int b = 30;
testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
Assert.assertTrue(true);
// testReporter.log(LogStatus.FA, "Loading the value of b to " + b);
reporter.endTest(testReporter);
}
@AfterMethod
public void tearDown(ITestResult result) {
if (result.getStatus() == ITestResult.FAILURE) {
testReporter.log(LogStatus.FAIL, "<pre>" + result.getThrowable().getMessage() + "</pre>");
}
}
@AfterSuite
public void afterSuite()
{
reporter.close();
}
}
非常感谢任何帮助!