Disclaimer: MashTips is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission at no extra cost to you.

Home Code How to Take Screenshot and save to Local Folder using Java and...

How to Take Screenshot and save to Local Folder using Java and Selenium Webriver

This is to take a screenshot of any web page and save the image into a local folder. This is based on Selenium Webdriver and currently supporting Firefox, Internet Explorer, Chrome, and Safari. The image can save to local folder with the current time as the image name.

Take Screenshot and save to Local Folder using Java and Selenium Webriver

import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;

public class ImageSave {
String imageName = System.currentTimeMillis() + ".png";

public void addScreenshot(WebDriver driver) throws IOException,
ClassNotFoundException, InterruptedException {
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("C://screenshot//" + imageName));


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Free Newsletter


10 Best iPhone Cases & Accessories for iPhone XR

The iPhone XR are here with a choice of six colors to match your personality. iPhone XR is designed and built as solid just as...

How to Control Music While Using Google Maps and Waze

Using your smartphone to navigate along a route is common. But, using your smartphones to control music playback using the Music Player apps is...

How to Download Netflix Movies and TV Shows.

Binge-watching Netflix on a weekend afternoon is a popular past time for many. All you need is a good Internet connection, a Netflix account...

10 Best Social Deduction Games Like ‘Among Us’

Among us has become one of the most addictive games recently. Social deduction games have begun to become favorites of a lot of people...

How to make your own hardware profile?

A hardware profile is a set of instructions that tells Windows which devices to start when you start your computer or which settings to...

How to get rid of BSD Root Error on iPhone?

Most of us faced BSD Root Error while jail breaking or doing some major change in default OS on your iOS device and it...
%d bloggers like this: