Class 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
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScreenShooterExtension

        public ScreenShooterExtension()
      • ScreenShooterExtension

        public ScreenShooterExtension​(boolean captureSuccessfulTests)
        Parameters:
        captureSuccessfulTests - param that indicate if need to capture successful tests
    • 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 interface org.junit.jupiter.api.extension.BeforeEachCallback
      • afterEach

        public void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback