Package org.openqa.selenium
Interface TakesScreenshot
- All Known Subinterfaces:
WebElement
- All Known Implementing Classes:
ChromeDriver
,ChromiumDriver
,EdgeDriver
,FirefoxDriver
,InternetExplorerDriver
,RemoteWebDriver
,RemoteWebElement
,SafariDriver
@NullMarked
public interface TakesScreenshot
Indicates a driver or an HTML element that can capture a screenshot and store it in different
ways.
Example usage:
File screenshotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); String screenshotBase64 = ((TakesScreenshot) element).getScreenshotAs(OutputType.BASE64);
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<X> X
getScreenshotAs
(OutputType<X> target) Capture the screenshot and store it in the specified location.
-
Method Details
-
getScreenshotAs
Capture the screenshot and store it in the specified location.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:
- Entire page
- Current window
- Visible portion of the current frame
- The screenshot of the entire display containing the browser
- The entire content of the HTML element
- The visible portion of the HTML element
- Type Parameters:
X
- Return type for getScreenshotAs.- Parameters:
target
- target type, @see OutputType- Returns:
- Object in which is stored information about the screenshot.
- Throws:
WebDriverException
- on failure.UnsupportedOperationException
- if the underlying implementation does not support screenshot capturing.
-