testing - Switching focus to a Popup window and taking a screenshot -
testing - Switching focus to a Popup window and taking a screenshot -
i'm writing testscript in selenium 2 takes screenshot of popup. popup window pdf.
after clicking link, i'm using code
try { file scrfile = ((takesscreenshot)driver).getscreenshotas(outputtype.file); fileutils.copyfile(scrfile, new file("c:\\tmp\\screenshot.png")); } grab (ioexception e) { e.printstacktrace(); } }
to take screenshot, however, takes shot of main page , not popup window. there way have selenium 2, alter focus new popup, take screenshot, , close popup , switch main window?
you have switch focus of driver this:
string mainwindow = driver.getwindowhandle(); (string handle : driver.getwindowhandles()) { if (!handle.equals(mainwindow)) { driver.switchto().window(handle) //put screenshot phone call here driver.close(); driver.switchto().window(mainwindow); } }
this of course of study take screenshot of other windows if got more of them. need know exact window handle , switcht that.
testing popup selenium-webdriver screenshot
Comments
Post a Comment