Package com.codeborne.selenide.junit5
Class ScreenShooterExtension
java.lang.Object
com.codeborne.selenide.junit5.ScreenShooterExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterTestExecutionCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
public class ScreenShooterExtension
extends Object
implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback
Use this class to automatically take screenshots in case of ANY errors in tests (not only Selenide errors).
How to use in Java:
@ExtendWith({ScreenShooterExtension.class})
public class MyTest {...}
How to use in Java (with customization):
public class MyTest {
@RegisterExtension
static ScreenShooterExtension screenshotEmAll = new ScreenShooterExtension(true);
...
}
How to use in Kotlin:
@ExtendWith(ScreenShooterExtension::class)
public class MyTest {...}
How to use in Kotlin (with customization):
public class MyTest { companion object {@JvmField
@RegisterExtension
val screenshotEmAll: ScreenShooterExtension = ScreenShooterExtension(true); } ... }
Restrictions:
This extension can only take screenshots for "static" webdriver managed by Selenide.
It doesn't take screenshots for webdrivers created by your code, e.g. using new SelenideDriver()
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterTestExecution
(org.junit.jupiter.api.extension.ExtensionContext context) void
beforeEach
(org.junit.jupiter.api.extension.ExtensionContext context) One-liner to configure Configuration.reportsFolder property.
-
Constructor Details
-
ScreenShooterExtension
public ScreenShooterExtension() -
ScreenShooterExtension
public ScreenShooterExtension(boolean captureSuccessfulTests) - Parameters:
captureSuccessfulTests
- param that indicate if you need to capture successful tests
-
-
Method Details
-
to
One-liner to configure Configuration.reportsFolder property.- Parameters:
folderWithScreenshots
- Folder to put screenshots to- Returns:
- current extension instance
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeEach
in interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
afterTestExecution
public void afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
afterTestExecution
in interfaceorg.junit.jupiter.api.extension.AfterTestExecutionCallback
-