Class ScreenShooter

java.lang.Object
org.junit.rules.TestWatcher
com.codeborne.selenide.junit.ScreenShooter
All Implemented Interfaces:
org.junit.rules.TestRule

@ParametersAreNonnullByDefault public class ScreenShooter extends org.junit.rules.TestWatcher
Usage:
  @Rule
 public ScreenShooter makeScreenshotOnFailure = ScreenShooter.failedTests();
or
  @Rule
 public ScreenShooter makeScreenshotOnEveryTest = ScreenShooter.failedTests().succeededTests();
or
  @Rule
 public ScreenShooter makeScreenshotOnEveryTest = ScreenShooter.failedTests().to("test-results/img/");

Restrictions:

This rule 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().

  • Field Details

    • captureSuccessfulTests

      public boolean captureSuccessfulTests
  • Method Details

    • failedTests

      @CheckReturnValue @Nonnull public static ScreenShooter failedTests()
    • succeededTests

      @Nonnull public ScreenShooter succeededTests()
    • starting

      protected void starting(org.junit.runner.Description test)
      Overrides:
      starting in class org.junit.rules.TestWatcher
    • succeeded

      protected void succeeded(org.junit.runner.Description test)
      Overrides:
      succeeded in class org.junit.rules.TestWatcher
    • failed

      protected void failed(Throwable e, org.junit.runner.Description description)
      Overrides:
      failed in class org.junit.rules.TestWatcher
    • finished

      protected void finished(org.junit.runner.Description description)
      Overrides:
      finished in class org.junit.rules.TestWatcher
    • to

      @Nonnull public ScreenShooter to(String folderWithScreenshots)
      One-liner to configure Configuration.reportsFolder property
      Parameters:
      folderWithScreenshots - Folder to put screenshots to