Selenium WebDriver Tutorial #38 – How to Take Screenshot in Selenium

In this selenium webdriver tutorial we will learn how to take Screenshot in Selenium WebDriver.

Selenium provides TakesScreenshot interface to capture the screenshots during script execution. TakesScreenshot interface has method getScreenshotAs( ) which is used for taking screenshots.

Taking screenshots when the test case fails is very common requirement in any test automation and your test automation framework should have capability to take screenshots in case you need them for reporting and debugging purposes.