Package com.version1.screenshots
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcucumberScreenshots(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 cucumberstatic voidtestNGScreenshots(org.testng.ITestResult result, org.openqa.selenium.support.events.EventFiringWebDriver webDriver, String folderPath) Capture screenshot whenever there is failure of a test method in testngMethods 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
-
Field Details
-
screenshotFile
-
targetLocation
-
reportsPath
-
testClassName
-
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 resultswebDriver- used to execute the testcasesLOG- for logging through concrete implementationstestId- 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 resultswebDriver- used to execute the testcasesfolderPath- for storing the screenshot
-