- Advertisement -
Capturing the screenshots during test executing plays important role to analyzing the failures in test execution. these days, most of framework has image capturing features. this image capturing also acts as test execution proof of particular test.
Selenium Webdriver provides the TakesScreenshoot interface for capturing a screenshot of entire webpage. this will helps automation engineer to helps in various ways such as
- Advertisement -
- to know state of the page
- Various variable values entered
- exceptions
- pop up dialog
- state of buttons, or state change by any action performed, etc
- output verification.
so, lets use this interface and save the file at desired location
public void takeScreenshot()
{
// Take Screenshot
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
// Save the file
FileUtils.copyFile(Screenshot, new File("C:\\Tests\\Test1\Screenshorts\screen1.png"));
}