@After(order = 10000) public void tearDown(Scenario scenario) { if (scenario.isFailed()) { final byte[] screenShot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.embed(screenShot, "failed.png"); } }
public void embedScreenshot(Scenario scenario) { try { byte[] screenshot = new SharedDriver().getScreenshotAs(OutputType.BYTES); scenario.embed(screenshot, "image/jpeg"); } catch (WebDriverException somePlatformsDontSupportScreenshots) { System.err.println(somePlatformsDontSupportScreenshots.getMessage()); } }
@After public void finish(Scenario scenario) { try { byte[] screenshot = webDriver.getScreenshotAs(OutputType.BYTES); scenario.embed(screenshot, "image/png"); } catch (WebDriverException somePlatformsDontSupportScreenshots) { System.err.println(somePlatformsDontSupportScreenshots.getMessage()); } finally { webDriver.close(); } }
@After public void tearDown(Scenario scenario) { try { if (scenario.isFailed()) { final byte[] screenshot = ((TakesScreenshot) WC.getDriver()).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshot, "image/png"); } } catch (Exception e) { LOG.error("error in taking screen shot ", e); } }
@After public void ShutDown(Scenario scenario) { if (scenario.isFailed()) { final byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshot, "image/png"); } System.out.println("Before Closing the driver in the test Set Up = " + driver); driver.close(); System.out.println("CLosed driver"); System.out.println("After Closing the getdriver in the test Set Up = " + driver); }
/** Embed a screenshot in test report if test is marked as failed */ @After public static void embedScreenshot(Scenario scenario) { if (scenario.isFailed()) { log.error( "Scenario failed! Browser: " + DriverManager.getBrowserInfo() + " Taking screenshot..."); scenario.write("Current Page URL is: " + DriverManager.getDriver().getCurrentUrl()); scenario.write("Scenario Failed in: " + DriverManager.getBrowserInfo()); try { byte[] screenshot = ((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES); scenario.embed(screenshot, "image/png"); } catch (WebDriverException somePlatformsDontSupportScreenshots) { log.error(somePlatformsDontSupportScreenshots.getMessage()); } } }