如何使用各个步骤的范围报告

时间:2018-04-20 05:00:48

标签: extentreports selenium-extent-report

我们如何为各个步骤使用范围报告日志。我的主要测试如下



@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之一的方法添加步骤,则系统会通过null值异常错误。

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();




1 个答案:

答案 0 :(得分:3)

如果要为loginToTenant方法创建单独的步骤,可以类似地在loginPage类中创建extentReport。它将为它创建单独的步骤。