Screenshots might give you a really useful information when you are trying to debug your tests. Here is how to take screenshots in selenium webdriver. First of all It depends when do you want to take the screenshot , that’s on you , I prefer to take screenshots only in case of failure. Inside your hooks file into After statement you need the following piece of code:
Take screenshots in using ruby capybara
Take screenshots in selenium webdriver
Here is how you can take screenshots in selenium using Java bindings or c# bindings:
Screenshots can really help you when you analyse your test failures
If you are using reports tools such as reportportal you don’t really have to worry about taking screenshots in case of failure because reportportal will take care of that and will automatically attach the image to the failure.
Also you should know that chromedriver doesn’t support to take screenshots for the entire page , at some point I wrote a pice o code in C# , I will share it with you in a separate post.