title: Extent Report 3 Add Screenshot
body: <p>I"m trying to build selenium with extent report but i could not get the save screenshot function working because i cannot reference the WebDriver object in the ITestListener class. Below is my sample code: </p>
  
  <p>Test Runner.java: </p>
  
  <pre><code>@Listeners({com.peterwkc.Listener.TestListener.class})
  public class ChromeTestManager {
  
      private WebDriverManager webDriverManager = new WebDriverManager();
      private WebDriver driver;
  
      private LoginPages loginPages;
      private AdminPages adminPages;
  
      @BeforeClass
      //@Parameters({"browser"})
      public void setupTest(/*String browser*/) throws MalformedURLException {
          System.out.println("BeforeMethod is started. " + Thread.currentThread().getId());
          // Set &amp; Get ThreadLocal Driver with Browser
  
          webDriverManager.createDriver("chrome");
          driver = webDriverManager.getDriver();
  
          // Pages Object Initialization
          loginPages = PageFactory.initElements(driver, LoginPages.class);
          logoutPages = PageFactory.initElements(driver, LogoutPages.class);
          adminPages = PageFactory.initElements(driver, AdminPages.class);
      }
  
      @DataProvider(name = "loginCredentials")
      public static Object[][] getLoginCredentials() {
          return new Object [][] {{ "Admin123", "admin123"  }, {"testUser", "test"}, {"test", "test"}};
      }
  
      @Test(groups= {"Login"}, description="Invalid Login", priority = 0, dataProvider = "loginCredentials", invocationCount = 3) 
      public void login_invalid(String username, String password) {
          loginPages.login_invalid(driver, username, password);
      }
  }
  </code></pre>
  
  <p>TestListener.java
      public class TestListener implements ITestListener {</p>
  
  <pre><code>    //Extent Report Declarations
      private static ExtentReports extent = ExtentManager.createInstance();
      private static ThreadLocal&lt;ExtentTest&gt; test = new ThreadLocal&lt;&gt;();
  
      public TestListener() {
      }
  
  @Override
      public synchronized void onTestFailure(ITestResult result) {
          System.out.println((result.getMethod().getMethodName() + " failed!"));
          test.get().fail("Exception Error : \n" + result.getThrowable());
  
          /*String feature = getClass().getName();
          String screenShot;
          try {
              screenShot = CaptureScreenshot.captureScreen(driver, CaptureScreenshot.generateFileName(feature));
              test.get().addScreenCaptureFromPath(screenShot);
              test.get().log(Status.FAIL, screenShot);
          } catch (IOException ex) {    
              LogManager.logger.log(Level.INFO, "Exception: " + ex.getMessage());
          }*/
  
      }
  }
  </code></pre>
  
  <p>Questions: </p>
  
  <ul>
  <li><p>How to pass the WebDriver object from TestRunner.java to TestListener
  class?</p></li>
  <li><p>How to save screenshot in extent report 3?</p></li>
  <li><p>Anything wrong with my code?</p></li>
  </ul>
  
  <p>please help, thanks in advance! </p>