Class Screenshots


  • @ParametersAreNonnullByDefault
    public class Screenshots
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Screenshots()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.util.List<java.io.File> finishContext()  
      static java.util.Optional<java.io.File> getLastContextScreenshot()
      Get the last screenshot taken in current context thread
      static java.io.File getLastScreenshot()
      Get the last screenshot taken
      static java.util.Optional<java.io.File> getLastThreadScreenshot()
      Get the last screenshot taken in current thread
      static java.lang.String saveScreenshotAndPageSource()  
      static void startContext​(java.lang.String className, java.lang.String methodName)  
      static java.lang.String takeScreenShot​(java.lang.String fileName)
      static Screenshot takeScreenShot​(java.lang.String className, java.lang.String methodName)  
      static java.io.File takeScreenShot​(org.openqa.selenium.WebElement element)
      Take screenshot of the WebElement/SelenideElement
      static java.io.File takeScreenShot​(org.openqa.selenium.WebElement iframe, org.openqa.selenium.WebElement element)
      Take screenshot of WebElement/SelenideElement in iframe for partially visible WebElement/Selenide horizontal scroll bar will be present
      static java.io.File takeScreenShotAsFile()
      Take screenshot and return as a file
      static java.awt.image.BufferedImage takeScreenShotAsImage​(org.openqa.selenium.WebElement element)
      Take screenshot of the WebElement/SelenideElement
      static java.awt.image.BufferedImage takeScreenShotAsImage​(org.openqa.selenium.WebElement iframe, org.openqa.selenium.WebElement element)
      Take screenshot of WebElement/SelenideElement in iframe for partially visible WebElement/Selenide horizontal scroll bar will be present
      • Methods inherited from class java.lang.Object

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

      • Screenshots

        public Screenshots()
    • Method Detail

      • saveScreenshotAndPageSource

        @CheckReturnValue
        public static java.lang.String saveScreenshotAndPageSource()
      • takeScreenShot

        @CheckReturnValue
        @Nonnull
        public static Screenshot takeScreenShot​(java.lang.String className,
                                                java.lang.String methodName)
      • takeScreenShotAsFile

        @CheckReturnValue
        @Nullable
        public static java.io.File takeScreenShotAsFile()
        Take screenshot and return as a file
        Returns:
        a temporary file, not guaranteed to be stored after tests complete.
      • takeScreenShot

        @CheckReturnValue
        @Nullable
        public static java.io.File takeScreenShot​(org.openqa.selenium.WebElement element)
        Take screenshot of the WebElement/SelenideElement
        Returns:
        a temporary file, not guaranteed to be stored after tests complete.
      • takeScreenShot

        @CheckReturnValue
        @Nullable
        public static java.io.File takeScreenShot​(org.openqa.selenium.WebElement iframe,
                                                  org.openqa.selenium.WebElement element)
        Take screenshot of WebElement/SelenideElement in iframe for partially visible WebElement/Selenide horizontal scroll bar will be present
        Returns:
        a temporary file, not guaranteed to be stored after tests complete.
      • takeScreenShotAsImage

        @CheckReturnValue
        @Nullable
        public static java.awt.image.BufferedImage takeScreenShotAsImage​(org.openqa.selenium.WebElement iframe,
                                                                         org.openqa.selenium.WebElement element)
        Take screenshot of WebElement/SelenideElement in iframe for partially visible WebElement/Selenide horizontal scroll bar will be present
        Returns:
        buffered image
      • takeScreenShotAsImage

        @CheckReturnValue
        @Nullable
        public static java.awt.image.BufferedImage takeScreenShotAsImage​(org.openqa.selenium.WebElement element)
        Take screenshot of the WebElement/SelenideElement
        Returns:
        buffered image
      • startContext

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

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

        @CheckReturnValue
        @Nullable
        public static java.io.File getLastScreenshot()
        Get the last screenshot taken
        Returns:
        null if there were no any screenshots taken
      • getLastThreadScreenshot

        @CheckReturnValue
        @Nonnull
        public static java.util.Optional<java.io.File> getLastThreadScreenshot()
        Get the last screenshot taken in current thread
        Returns:
        Optional with screenshot of current thread, or an empty Optional if there were no any screenshots taken.
      • getLastContextScreenshot

        @CheckReturnValue
        @Nonnull
        public static java.util.Optional<java.io.File> getLastContextScreenshot()
        Get the last screenshot taken in current context thread
        Returns:
        Optional with screenshot of current context thread, or an empty Optional if there were no any screenshots taken.