How to take Screenshot using Selenium Webdriver.

Hello Geek’s, hope you are doing well. Today I’m gonna show you how to take a screen shot using Selenium webdriver. In the Test Automation world many a times you will need to take screen shot of your web browser, compare it with the other images/screen shots, or you might want to do it for analyzing the quality of your web pages, yes they do this in Google to check if the web pages looks beautiful and each and everything, every element is in its right place, only a human can do that. So they take screen shots and analyze them manually,  or simply you want to store/capture the script work flow.

Oh..! you may wonder whats in the doodle, it was Minna Canth’s 173rd birthday.

I love to use java client for Selenium Webdriver, you are free to use languages supported by Selenium, almost every language supported by Selenium has this feature, I will show you how to take screen shot using Java, Python, C#, JavaScript and Ruby.

Java :

 We will use TakesScreenshot Interface from Selenium webdriver, and call getScreenshotAs() method of its object. We need to caste WebDriver interface to TakesScreenshot, because the WebDriver instance does not contain the getScreenshotAs() method.

Python : Pretty Simple…

JavaScript :

C# :

Ruby :