online virus scanner_f

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.main;
 
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 comment