Index: ssts-web/src/test/java/test/forgon/disinfectsystem/selenium/ALL.java =================================================================== diff -u -r18689 -r18695 --- ssts-web/src/test/java/test/forgon/disinfectsystem/selenium/ALL.java (.../ALL.java) (revision 18689) +++ ssts-web/src/test/java/test/forgon/disinfectsystem/selenium/ALL.java (.../ALL.java) (revision 18695) @@ -9,8 +9,11 @@ import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebElement; +import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.os.WindowsUtils; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.remote.SessionId; import org.testng.AssertJUnit; import org.testng.annotations.AfterTest; import org.testng.annotations.Test; @@ -387,16 +390,28 @@ @AfterTest public void afterMethod() { try { - File scrFile = ((TakesScreenshot) Utils.driver) - .getScreenshotAs(OutputType.FILE); - // Now you can do whatever you need to do with it, for example - // copy - // somewhere - - String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss") - .format(new java.util.Date()); - FileUtils.copyFile(scrFile, new File("c:\\temp\\screenshot-" - + timeStamp + ".png")); + + SessionId session = null; + + if (Utils.driver instanceof RemoteWebDriver){ + session = ((RemoteWebDriver)Utils.driver).getSessionId(); + } + else if (Utils.driver instanceof InternetExplorerDriver){ + session = ((InternetExplorerDriver)Utils.driver).getSessionId(); + } + + if (session != null){ + File scrFile = ((TakesScreenshot) Utils.driver) + .getScreenshotAs(OutputType.FILE); + // Now you can do whatever you need to do with it, for example + // copy + // somewhere + + String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss") + .format(new java.util.Date()); + FileUtils.copyFile(scrFile, new File("c:\\temp\\screenshot-" + + timeStamp + ".png")); + } } catch (Exception e) { e.printStackTrace(); }