I'm writing a testscript in selenium 2 that takes a screenshot of a popup. The popup window is a pdf.
After clicking the link, I'm using the code
try {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
To take a screenshot, however, that only takes a shot of the main page and not the popup window. Is there a way to have selenium 2, change focus to the new popup, take the screenshot, and then close the popup and switch back to the main window?