Class CaptureScreenshots

java.lang.Object
org.testng.TestListenerAdapter
com.version1.screenshots.CaptureScreenshots
All Implemented Interfaces:
org.testng.IConfigurationListener, org.testng.IConfigurationListener2, org.testng.internal.IResultListener, org.testng.internal.IResultListener2, org.testng.ITestListener, org.testng.ITestNGListener

public class CaptureScreenshots extends org.testng.TestListenerAdapter
Captures the Screenshots whenever there is any test failure Consists of two different implementations methods for cucumber and testng.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
     
    static File
     
    static File
     
    static String
     
    static String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    cucumberScreenshots(cucumber.api.Scenario scenario, org.openqa.selenium.support.events.EventFiringWebDriver webDriver, org.slf4j.Logger LOG, String testId)
    Capture screenshot whenever there is failure of a scenerio in cucumber
    static void
    testNGScreenshots(org.testng.ITestResult result, org.openqa.selenium.support.events.EventFiringWebDriver webDriver, String folderPath)
    Capture screenshot whenever there is failure of a test method in testng

    Methods inherited from class org.testng.TestListenerAdapter

    beforeConfiguration, getAllTestMethods, getConfigurationFailures, getConfigurationSkips, getFailedButWithinSuccessPercentageTests, getFailedTests, getPassedTests, getSkippedTests, getTestContexts, onConfigurationFailure, onConfigurationSkip, onConfigurationSuccess, onFinish, onStart, onTestFailedButWithinSuccessPercentage, onTestFailure, onTestSkipped, onTestStart, onTestSuccess, setAllTestMethods, setFailedButWithinSuccessPercentageTests, setFailedTests, setPassedTests, setSkippedTests, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • screenshotFile

      public static File screenshotFile
    • targetLocation

      public static String targetLocation
    • reportsPath

      public static String reportsPath
    • testClassName

      public static String testClassName
    • targetFile

      public static File targetFile
  • Constructor Details

    • CaptureScreenshots

      public CaptureScreenshots()
  • Method Details

    • cucumberScreenshots

      public static void cucumberScreenshots(cucumber.api.Scenario scenario, org.openqa.selenium.support.events.EventFiringWebDriver webDriver, org.slf4j.Logger LOG, String testId)
      Capture screenshot whenever there is failure of a scenerio in cucumber
      Parameters:
      scenario - for inspecting results
      webDriver - used to execute the testcases
      LOG - for logging through concrete implementations
      testId - of the execution generated randomly using base encoding
    • testNGScreenshots

      public static void testNGScreenshots(org.testng.ITestResult result, org.openqa.selenium.support.events.EventFiringWebDriver webDriver, String folderPath)
      Capture screenshot whenever there is failure of a test method in testng
      Parameters:
      result - of type ITestResult for inspecting results
      webDriver - used to execute the testcases
      folderPath - for storing the screenshot