Class Screenshots

java.lang.Object
com.codeborne.selenide.Screenshots

public class Screenshots extends Object
  • Field Details

  • Constructor Details

    • Screenshots

      public Screenshots()
  • Method Details

    • saveScreenshotAndPageSource

      public static String saveScreenshotAndPageSource()
    • takeScreenShot

      public static Screenshot takeScreenShot(String className, String methodName)
    • takeScreenShotAsFile

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

      public static 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

      public static @Nullable File takeScreenShot(org.openqa.selenium.WebElement iframe, SelenideElement 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

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

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

      public static void startContext(String className, String methodName)
    • finishContext

      @CanIgnoreReturnValue public static List<Screenshot> finishContext()
    • getLastScreenshot

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

      public static Optional<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

      public static Optional<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.