我们如何将范围报告日志用于各个步骤。我的主要测试如下
@Test(testName = "Validate SinglePage and Multiple Page", enabled = true, priority = 1, groups = {"Section Formatting"})
public void SingleSection(String username, String password, String viewName, String r1, String r2, String r3, String r4, String r5, String SecItem1, String SecItem2, String DispStyle, String fType) throws InterruptedException {
extentTest = extent.startTest("SingleSection");
extentTest.log(LogStatus.INFO, "Login to the system");
login.loginToTenant(username, password);
extentTest.log(LogStatus.INFO, "Access the content menu");
// select view from content menu button
createContentMenuButton.setContentMenuButton();
extentTest.log(LogStatus.INFO, "Select the view");
// choose view
reportView.selectView(viewName);
extentTest.log(LogStatus.INFO, "Create the report");
// create the report in report builder
createChart.createReport(r1, r2, r3, r4, r5);
extentTest.log(LogStatus.INFO, "Add fields to sections");
// Adds fields to sections
sections.dragAndDropToSections(SecItem1, SecItem2);
例如,如果我想为 ex-loginToTenant 方法之一设置步骤,系统会出现空值异常错误。
loginToTenant 方法的代码如下
public class loginPage extends ConfigReader {
WebDriver driver;
public ExtentReports extent;
public ExtentTest extentTest;
public loginPage(WebDriver driver) {
this.driver = driver;
}
// locators for login page
By userName = By.name("email");
By password = By.name("password");
By submitButton = By.id("logonButton");
By licenseWarning = By.partialLinkText("Click Here To Continue");
By plusButton = By.className("create-menu-container");
By banner = By.className("i4sidenav_width");
By logout = By.id("logoffBtn");
/**
* perform login to yellowfin and verify successful login
*
* @param uName
* @param passwd
* @return
*/
public String loginToTenant(String uName, String passwd) {
String loginmsg = null;
long d = 1000;
try {
extentTest.log(LogStatus.INFO, "Login to the system"); //I am getting an error on this line with null pointer exception
driver.findElement(userName).clear();
driver.findElement(userName).sendKeys(uName);
driver.findElement(password).clear();
driver.findElement(password).sendKeys(passwd);
driver.findElement(submitButton).click();