java - Selenium2 Webdriver taking screen shot works for Firefox but nothing else -
i using selenium 2 testng. selenium-java-2.33.0
trying take screen shot of browser on failed test cases. storing webdriver in hashtable id associated each browser type (ie, firefox, chrome, , safari). in cleanup routine "@aftermethod", fetch webdriver. here code:
//code 1:
if (webdriver instanceof takesscreenshot) { file tempfile = ((takesscreenshot)driver).getscreenshotas(outputtype.file); fileutils.copyfile(tempfile, new file("screenshots.png")); }
//code 2:
eventfiringwebdriver efiringdriver = new eventfiringwebdriver(webdriver); file scrfile = efiringdriver.getscreenshotas(outputtype.file); fileutils.copyfile(scrfile, new file("screenshot.png"));
both of code paths works firefox, other browsers, cast exception thrown.
java.lang.classcastexception: org.openqa.selenium.chrome.chromedriver cannot cast org.openqa.selenium.firefox.firefoxdriver
Comments
Post a Comment