How can I take a screenshot with Selenium WebDriver? (Java)

How can I take a screenshot with Selenium WebDriver? (Java)

You can save screenshots using the TakeScreenshot driver. These screenshots can be taken with three output types: byte array, Base64 or File.


byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);

With MaxTAF you can immediately see the screenshot after the test is run if you use the save screenshot code seen in the script for this example.


mxService.saveScreenshot(screenshot);

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.