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 this entry
You’re currently reading “Capturing web page screenshot using WebDriver API,” an entry on Singaram's Tech Musings
- Published:
- May 8, 2011 / 12:55 PM
- Category:
- Open Source, Selenium
- Tags:
- Commons IO, WebDriver

2 Comments
Jump to comment form | comment rss [?] | trackback uri [?]