有没有办法在扩展报告中打印测试用例的各个步骤



有没有办法在范围报告中打印测试步骤? 登录测试用例示例,我想打印

1.输入用户名 2. 输入密码 3. 点击登录按钮

也许如果在状态,时间戳和详细信息之后,可以添加步骤

我在框架中使用 ExtentReport,就像下面的代码一样,我对此非常满意。希望下面的示例代码对您有用

// initialize the HtmlReporter
public ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("C:\report\path\to\report.html");
// initialize the report
public ExtentReports report  = new ExtentReports();
// initialize the report
public ExtentTest logger ;
//ExtentHtmlReporter and ExtentXReporter allow appending test information to an existing report.
htmlReporter.setAppendExisting(true);
// attach only HtmlReporter
report.attachReporter(htmlReporter);
//Create main test cases
logger = report.createTest("Driver Initialization");
logger.log(Status.INFO, "Starting firefox browser");
System.setProperty("webdriver.gecko.driver", "path\to\geckodriver\geckodriver.exe");
driver = new FirefoxDriver();
logger.log(Status.INFO, "Browser started");
driver.get("www.facebook.com");
logger.log(Status.INFO, "Title is: "+driver.getTitle());
logger.log.(Status.PASS, "Application opened");
driver.findElement(By.id("username")).sendKeys("validuser");
logger.log(Status.INFO, "username entered");
driver.findElement(By.id("password")).sendKeys("validpassword");
logger.log(Status.INFO, "Password entered");
driver.findElement(By.id("login")).click();
logger.log(Status.INFO, "login button clicked");
logger.log(Status.PASS, "Home page opened");
//Simply call the flush() method to write or update test information to your reporter. 
report.flush();
driver.quite();

如果您有任何疑问,请告诉我。

最新更新