Class ScreenShotLaboratory


  • @ParametersAreNonnullByDefault
    public class ScreenShotLaboratory
    extends java.lang.Object
    • Field Detail

      • allScreenshots

        protected final java.util.List<java.io.File> allScreenshots
      • screenshotCounter

        protected java.util.concurrent.atomic.AtomicLong screenshotCounter
      • currentContext

        protected java.lang.ThreadLocal<java.lang.String> currentContext
      • currentContextScreenshots

        protected java.lang.ThreadLocal<java.util.List<java.io.File>> currentContextScreenshots
      • threadScreenshots

        protected java.lang.ThreadLocal<java.util.List<java.io.File>> threadScreenshots
    • Constructor Detail

      • ScreenShotLaboratory

        protected ScreenShotLaboratory()
      • ScreenShotLaboratory

        protected ScreenShotLaboratory​(Photographer photographer,
                                       PageSourceExtractor extractor,
                                       com.codeborne.selenide.impl.Clock clock)
    • Method Detail

      • takeScreenShot

        @CheckReturnValue
        @Nonnull
        public Screenshot takeScreenShot​(Driver driver,
                                         java.lang.String className,
                                         java.lang.String methodName)
      • getScreenshotFileName

        @CheckReturnValue
        @Nonnull
        protected java.lang.String getScreenshotFileName​(java.lang.String className,
                                                         java.lang.String methodName)
      • takeScreenShot

        @CheckReturnValue
        @Nullable
        @Deprecated
        public java.lang.String takeScreenShot​(Driver driver)
        Deprecated.
        use takeScreenshot(Driver) which returns Screenshot instead of String
      • takeScreenShot

        @CheckReturnValue
        @Nullable
        @Deprecated
        public java.lang.String takeScreenShot​(Driver driver,
                                               java.lang.String fileName)
        Deprecated.
        use takeScreenshot(Driver, String) which returns Screenshot instead of String
        Takes screenshot of current browser window. Stores 2 files: html of page (if "savePageSource" option is enabled), and (if possible) image in PNG format.
        Parameters:
        fileName - name of file (without extension) to store screenshot to.
        Returns:
        the name of last saved screenshot or null if failed to create screenshot
      • takeScreenshot

        @CheckReturnValue
        @Nonnull
        public Screenshot takeScreenshot​(Driver driver,
                                         java.lang.String fileName)
        Takes screenshot of current browser window. Stores 2 files: html of page (if "savePageSource" option is enabled), and (if possible) image in PNG format.
        Parameters:
        fileName - name of file (without extension) to store screenshot to.
        Returns:
        instance of Screenshot containing both files
      • takeScreenShot

        @CheckReturnValue
        @Nullable
        public <T> T takeScreenShot​(Driver driver,
                                    org.openqa.selenium.OutputType<T> outputType)
      • takeScreenshot

        @CheckReturnValue
        @Nullable
        public java.io.File takeScreenshot​(Driver driver,
                                           org.openqa.selenium.WebElement element)
      • takeScreenshotAsImage

        @CheckReturnValue
        @Nullable
        public java.awt.image.BufferedImage takeScreenshotAsImage​(Driver driver,
                                                                  org.openqa.selenium.WebElement element)
      • generateScreenshotFileName

        @CheckReturnValue
        @Nonnull
        protected java.lang.String generateScreenshotFileName()
      • takeScreenshot

        @CheckReturnValue
        @Nullable
        public java.io.File takeScreenshot​(Driver driver,
                                           org.openqa.selenium.WebElement iframe,
                                           org.openqa.selenium.WebElement element)
      • takeScreenshotAsImage

        @CheckReturnValue
        @Nullable
        public java.awt.image.BufferedImage takeScreenshotAsImage​(Driver driver,
                                                                  org.openqa.selenium.WebElement iframe,
                                                                  org.openqa.selenium.WebElement element)
      • takeScreenShotAsFile

        @CheckReturnValue
        @Nullable
        public java.io.File takeScreenShotAsFile​(Driver driver)
      • addToHistory

        @Nonnull
        protected java.io.File addToHistory​(java.io.File screenshot)
      • savePageImageToFile

        @CheckReturnValue
        @Nullable
        protected java.io.File savePageImageToFile​(Config config,
                                                   java.lang.String fileName,
                                                   Driver driver)
      • savePageSourceToFile

        @CheckReturnValue
        @Nonnull
        protected java.io.File savePageSourceToFile​(Config config,
                                                    java.lang.String fileName,
                                                    Driver driver)
      • startContext

        public void startContext​(java.lang.String className,
                                 java.lang.String methodName)
      • startContext

        public void startContext​(java.lang.String context)
      • finishContext

        @Nonnull
        public java.util.List<java.io.File> finishContext()
      • getScreenshots

        @CheckReturnValue
        @Nonnull
        public java.util.List<java.io.File> getScreenshots()
      • getThreadScreenshots

        @CheckReturnValue
        @Nonnull
        public java.util.List<java.io.File> getThreadScreenshots()
      • getContextScreenshots

        @CheckReturnValue
        @Nonnull
        public java.util.List<java.io.File> getContextScreenshots()
      • getLastScreenshot

        @CheckReturnValue
        @Nullable
        public java.io.File getLastScreenshot()
      • getLastThreadScreenshot

        @CheckReturnValue
        @Nonnull
        public java.util.Optional<java.io.File> getLastThreadScreenshot()
      • getLastContextScreenshot

        @CheckReturnValue
        @Nonnull
        public java.util.Optional<java.io.File> getLastContextScreenshot()
      • formatScreenShotPath

        @CheckReturnValue
        @Nonnull
        @Deprecated
        public java.lang.String formatScreenShotPath​(Driver driver)
        Deprecated.
        Use method takeScreenshot(Driver) which returns Screenshot instead of String
      • takeScreenshot

        @CheckReturnValue
        @Nonnull
        public Screenshot takeScreenshot​(Driver driver)