Capturing web page screenshot using WebDriver API


You can use the below snippet to take screenshot and save it where you want. Commons IO libraries can be downloaded here: http://commons.apache.org/io/download_io.cgi


...
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
//Needs Commons IO library
FileUtils.copyFile(scrFile, new File("c:\\screenshot\\googlesearch-webdriverapi.png"));
...

About these ads

About this entry