public interface TakesScreenshot
Example usage:
File screenshotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); String screenshotBase64 = ((TakesScreenshot) element).getScreenshotAs(OutputType.BASE64);
OutputType
Modifier and Type | Method and Description |
---|---|
<X> X |
getScreenshotAs(OutputType<X> target)
Capture the screenshot and store it in the specified location.
|
<X> X getScreenshotAs(OutputType<X> target) throws WebDriverException
For a W3C-conformant WebDriver or WebElement, this behaves as stated in W3C WebDriver specification.
For a non-W3C-conformant WebDriver, this makes a best effort depending on the browser to return the following in order of preference:
X
- Return type for getScreenshotAs.target
- target type, @see OutputTypeWebDriverException
- on failure.java.lang.UnsupportedOperationException
- if the underlying implementation does not support
screenshot capturing.