Log in
updated 11:29 AM UTC, May 4, 2016

How to take a screenshot of the website using selenium webdriver for java

  • Written by Madhu V Rao
  • Published in Automation

This code snippet shows how to take a screenshot in selenium java webdriver


public void take_a_copy_of_screenshot(String fileName) throws IOException {
		File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
		FileUtils.copyFile(screenshot, new File(YOUR_FOLDER + "\\" + YOURFILENAME + ".png"));	

TakeScreenshot class is from selenium

import org.openqa.selenium.TakesScreenshot;

Powered by Bullraider.com
Follow Us on Twitter
Find Us on Facebook
Follow Us on Google
Follow Us on Pinterest