Package com.codeborne.selenide.impl
Class ScreenShotLaboratory
- java.lang.Object
-
- com.codeborne.selenide.impl.ScreenShotLaboratory
-
@ParametersAreNonnullByDefault public class ScreenShotLaboratory extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.io.File>allScreenshotsprotected java.lang.ThreadLocal<java.lang.String>currentContextprotected java.lang.ThreadLocal<java.util.List<java.io.File>>currentContextScreenshotsprotected java.util.concurrent.atomic.AtomicLongscreenshotCounterprotected java.lang.ThreadLocal<java.util.List<java.io.File>>threadScreenshots
-
Constructor Summary
Constructors Modifier Constructor Description protectedScreenShotLaboratory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.io.FileaddToHistory(java.io.File screenshot)protected voidensureFolderExists(java.io.File targetFile)java.util.List<java.io.File>finishContext()java.lang.StringformatScreenShotPath(Driver driver)protected java.lang.StringgenerateScreenshotFileName()java.util.List<java.io.File>getContextScreenshots()static ScreenShotLaboratorygetInstance()java.util.Optional<java.io.File>getLastContextScreenshot()java.io.FilegetLastScreenshot()java.util.Optional<java.io.File>getLastThreadScreenshot()protected java.io.FilegetPageImage(org.openqa.selenium.WebDriver webdriver)protected java.lang.StringgetScreenshotFileName(java.lang.String className, java.lang.String methodName)java.util.List<java.io.File>getScreenshots()java.util.List<java.io.File>getThreadScreenshots()protected java.io.FilesavePageImageToFile(Config config, java.lang.String fileName, org.openqa.selenium.WebDriver webdriver)protected java.io.FilesavePageSourceToFile(Config config, java.lang.String fileName, org.openqa.selenium.WebDriver webdriver)voidstartContext(java.lang.String context)voidstartContext(java.lang.String className, java.lang.String methodName)java.io.FiletakeScreenshot(Driver driver, org.openqa.selenium.WebElement element)java.io.FiletakeScreenshot(Driver driver, org.openqa.selenium.WebElement iframe, org.openqa.selenium.WebElement element)java.lang.StringtakeScreenShot(Driver driver)java.lang.StringtakeScreenShot(Driver driver, java.lang.String fileName)Takes screenshot of current browser window.java.lang.StringtakeScreenShot(Driver driver, java.lang.String className, java.lang.String methodName)java.io.FiletakeScreenShotAsFile(Driver driver)java.awt.image.BufferedImagetakeScreenshotAsImage(Driver driver, org.openqa.selenium.WebElement element)java.awt.image.BufferedImagetakeScreenshotAsImage(Driver driver, org.openqa.selenium.WebElement iframe, org.openqa.selenium.WebElement element)protected java.io.FiletakeScreenshotImage(Config config, org.openqa.selenium.TakesScreenshot driver, java.lang.String fileName)protected java.io.FiletakeScreenshotInMemory(org.openqa.selenium.TakesScreenshot driver)protected longtimestamp()
-
-
-
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
-
-
Method Detail
-
getInstance
public static ScreenShotLaboratory getInstance()
-
takeScreenShot
@CheckReturnValue @Nullable public java.lang.String 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 public java.lang.String takeScreenShot(Driver driver)
-
takeScreenShot
@CheckReturnValue @Nullable public java.lang.String 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:
- the name of last saved screenshot or null if failed to create screenshot
-
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()
-
ensureFolderExists
protected void ensureFolderExists(java.io.File targetFile)
-
timestamp
protected long timestamp()
-
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)
-
getPageImage
@CheckReturnValue @Nullable protected java.io.File getPageImage(org.openqa.selenium.WebDriver webdriver)
-
addToHistory
@Nonnull protected java.io.File addToHistory(java.io.File screenshot)
-
takeScreenshotInMemory
@CheckReturnValue @Nullable protected java.io.File takeScreenshotInMemory(org.openqa.selenium.TakesScreenshot driver)
-
savePageImageToFile
@CheckReturnValue @Nullable protected java.io.File savePageImageToFile(Config config, java.lang.String fileName, org.openqa.selenium.WebDriver webdriver)
-
savePageSourceToFile
@CheckReturnValue @Nonnull protected java.io.File savePageSourceToFile(Config config, java.lang.String fileName, org.openqa.selenium.WebDriver webdriver)
-
takeScreenshotImage
@CheckReturnValue @Nullable protected java.io.File takeScreenshotImage(Config config, org.openqa.selenium.TakesScreenshot driver, java.lang.String fileName)
-
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 public java.lang.String formatScreenShotPath(Driver driver)
-
-