Capture Screenshot in Selenium

Let’s see how can you capture screenshot in Selenium. In automation, it is mandatory to take the screenshot for verification so that can prove also that your test case has covered certain functionality or not.

 

Screenshots help you a lot when your test case will fail so that you can identify what went wrong in your script or in your application.

In selenium WebDriver, we can take the screen shot using the below command.

Let’s design a Selenium script which will capture the Screenshot.

 

Video Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

 

Taking ScreenShot for Only Failed Test Case

We are designing the Test Script in Selenium for FaceBook Login, It will capture the screenshot only when Test will fail. (So we will fail the Test explicitly using dummy username and password) .

 

The above test case will fail and it will capture the screenshot and save to the D drive.

You can execute this code on your local machine.

0 Comment

Leave a Reply