Pages

Friday, 9 March 2012

How to take screenshot of the test page?

We can take entire page screenshot by following code:


   //Instantiate any WebDriver; Eg. Firefox
WebDriver driver = new FirefoxDriver();
driver.get("http://seleniumwebdriverfaq.tumblr.com/");
//Get the screenshot as file
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Copy the screenshot to your file system
FileUtils.copyFile(scrFile, new File("c:\screenshots\screenshot.png"));

No comments:

Post a Comment