content: package com.anhtester.listeners;
  
  import com.anhtester.driver.DriverManager;
  import io.qameta.allure.Allure;
  import io.qameta.allure.listener.TestLifecycleListener;
  import io.qameta.allure.model.Status;
  import io.qameta.allure.model.TestResult;
  import org.openqa.selenium.OutputType;
  import org.openqa.selenium.TakesScreenshot;
  
  import java.io.ByteArrayInputStream;
  
  public class AllureListener implements TestLifecycleListener {
  
      @Override
      public void beforeTestSchedule(TestResult result) {
      }
  
      @Override
      public void afterTestSchedule(TestResult result) {
      }
  
      @Override
      public void beforeTestUpdate(TestResult result) {
      }
  
      @Override
      public void afterTestUpdate(TestResult result) {
      }
  
      @Override
      public void beforeTestStart(TestResult result) {
      }
  
      @Override
      public void afterTestStart(TestResult result) {
      }
  
      @Override
      public void beforeTestStop(TestResult result) {
          if (result.getStatus() == Status.FAILED || result.getStatus() == Status.BROKEN) {
  //            if (DriverManager.getDriver() != null) {
  //                Allure.addAttachment(result.getName(), new ByteArrayInputStream(((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES)));
  //            }
          }
      }
  
      @Override
      public void afterTestStop(TestResult result) {
      }
  
      @Override
      public void beforeTestWrite(TestResult result) {
      }
  
      @Override
      public void afterTestWrite(TestResult result) {
      }
  
  }
  