Package com.codeborne.selenide.impl
Class ScreenShotLaboratory
- java.lang.Object
-
- com.codeborne.selenide.impl.ScreenShotLaboratory
-
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.AtomicLongscreenshotCounter
-
Constructor Summary
Constructors Constructor Description ScreenShotLaboratory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.io.FileaddToHistory(java.io.File screenshot)protected voidcopyFile(java.io.File sourceFile, java.io.File targetFile)protected voidcopyFile(java.io.InputStream in, java.io.File targetFile)protected voidensureFolderExists(java.io.File targetFile)java.util.List<java.io.File>finishContext()java.lang.StringformatScreenShotPath(Driver driver)protected java.lang.StringgenerateScreenshotFileName()static ScreenShotLaboratorygetInstance()java.io.FilegetLastScreenshot()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()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
-
-
Method Detail
-
getInstance
public static ScreenShotLaboratory getInstance()
-
takeScreenShot
public java.lang.String takeScreenShot(Driver driver, java.lang.String className, java.lang.String methodName)
-
getScreenshotFileName
protected java.lang.String getScreenshotFileName(java.lang.String className, java.lang.String methodName)
-
takeScreenShot
public java.lang.String takeScreenShot(Driver driver)
-
takeScreenShot
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
public java.io.File takeScreenshot(Driver driver, org.openqa.selenium.WebElement element)
-
takeScreenshotAsImage
public java.awt.image.BufferedImage takeScreenshotAsImage(Driver driver, org.openqa.selenium.WebElement element)
-
generateScreenshotFileName
protected java.lang.String generateScreenshotFileName()
-
ensureFolderExists
protected void ensureFolderExists(java.io.File targetFile)
-
timestamp
protected long timestamp()
-
takeScreenshot
public java.io.File takeScreenshot(Driver driver, org.openqa.selenium.WebElement iframe, org.openqa.selenium.WebElement element)
-
takeScreenshotAsImage
public java.awt.image.BufferedImage takeScreenshotAsImage(Driver driver, org.openqa.selenium.WebElement iframe, org.openqa.selenium.WebElement element)
-
takeScreenShotAsFile
public java.io.File takeScreenShotAsFile(Driver driver)
-
getPageImage
protected java.io.File getPageImage(org.openqa.selenium.WebDriver webdriver)
-
addToHistory
protected java.io.File addToHistory(java.io.File screenshot)
-
takeScreenshotInMemory
protected java.io.File takeScreenshotInMemory(org.openqa.selenium.TakesScreenshot driver)
-
savePageImageToFile
protected java.io.File savePageImageToFile(Config config, java.lang.String fileName, org.openqa.selenium.WebDriver webdriver)
-
savePageSourceToFile
protected java.io.File savePageSourceToFile(Config config, java.lang.String fileName, org.openqa.selenium.WebDriver webdriver)
-
takeScreenshotImage
protected java.io.File takeScreenshotImage(Config config, org.openqa.selenium.TakesScreenshot driver, java.lang.String fileName)
-
copyFile
protected void copyFile(java.io.File sourceFile, java.io.File targetFile) throws java.io.IOException- Throws:
java.io.IOException
-
copyFile
protected void copyFile(java.io.InputStream in, java.io.File targetFile) throws java.io.IOException- Throws:
java.io.IOException
-
startContext
public void startContext(java.lang.String className, java.lang.String methodName)
-
startContext
public void startContext(java.lang.String context)
-
finishContext
public java.util.List<java.io.File> finishContext()
-
getScreenshots
public java.util.List<java.io.File> getScreenshots()
-
getLastScreenshot
public java.io.File getLastScreenshot()
-
formatScreenShotPath
public java.lang.String formatScreenShotPath(Driver driver)
-
-