Home > Selenium > Take screenshot or print screen using selenium

Take screenshot or print screen using selenium

This post was most recently updated on June 14th, 2019

For analysis , debugging and reporting it is important to take screenshot in any state of script execution. To achieve this in selenium we need to follow below steps

  1. Include library import org.openqa.selenium.TakesScreenshot;
  2. create object and call getScreenshotAs method
  3. And paste the file into proper location using FileUtils method copyFile.

Type cast the TakesScreenshot Interface:

Call getScreenshotAs method:

Create new file to store the data:

Copy the content of source to destination file:

Complete code:

Selenium Tutorial >>

This Article is TAGGED in . BOOKMARK THE permalink.

Avatar photo
Amit Bharamasali
Automation Software Test Engineer. Skills: Manual Testing, Selenium, Java, Protractor, JavaScript, Katalon Studio, Groovy, Appium, Sahi, Sahi Script and UI/UX testing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">