in Selenium by

How to capture Screenshot in Selenium WebDriver?

1 Answer

0 votes
Test cases may fail while executing the test scripts. While we are executing the test cases manually we just take a screenshot and place in a result repository. The same can be done by using Selenium WebDriver.

Some of the scenarios we may need to capture a screenshot using Selenium WebDriver are

i. Application issues

ii. Assertion Failure

iii. Difficulty to find Webelements on the web page

iv. Timeout to find Webelements on the web page

Selenium provides an interface called TakesScreenshot which has a method getScreenShotAs which can be used to take a screenshot of the application under test.

In Selenium 3, we may face few issues while capturing Screenshots. To overcome we use aShot utility. Click on below links to see posts related to the normal way of capturing a screenshot and capturing a screenshot using aShot utility.

Capture screenshot using Selenium WebDriver

Full Page Screenshot using aShot utility

Failed Test Cases Screenshot