Package com.codeborne.selenide.junit5
Class ScreenShooterExtension
- java.lang.Object
-
- com.codeborne.selenide.junit5.ScreenShooterExtension
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
@ParametersAreNonnullByDefault public class ScreenShooterExtension extends java.lang.Object implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
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); } ... }- Since:
- 4.12.2
-
-
Constructor Summary
Constructors Constructor Description ScreenShooterExtension()
ScreenShooterExtension(boolean captureSuccessfulTests)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
void
beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
ScreenShooterExtension
to(java.lang.String folderWithScreenshots)
One-liner to configure Configuration.reportsFolder property.
-
-
-
Method Detail
-
to
@Nonnull public ScreenShooterExtension to(java.lang.String folderWithScreenshots)
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
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
- Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
-
-