Q:

How to use extent reports for individual steps

How can we use extent report logs for individual steps. My main test is as follows

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

For example If I want to put steps for one of the methods ex- loginToTenant, the system throughs null value exception error.
the code for the method loginToTenant is as follows

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

A:

If you wants to create individual steps for loginToTenant method, you can create extentReport in loginPage class similarly. And it will create individual steps for it.

