@Override
 public void onTestSkipped(ITestResult result) {
   if (result
       .getMethod()
       .getConstructorOrMethod()
       .getMethod()
       .isAnnotationPresent(DontRun.class)) {
     log("Test SKIPPED", "this test is not supported in this environment", true);
     result.setStatus(ITestResult.SUCCESS);
     onTestSuccess(result);
   } else {
     result.setStatus(ITestResult.FAILURE);
     result.setThrowable(new SkipException("TEST SKIPPED"));
     onTestFailure(result);
   }
 }
  @Override
  public void onTestFailure(ITestResult result) {
    driver = NewDriverProvider.getWebDriver();
    if (driver == null) {
      driver = NewDriverProvider.getWebDriver();
    }

    imageCounter += 1;
    if ("true".equals(Configuration.getLogEnabled())) {
      try {
        new Shooter().savePageScreenshot(screenPath + imageCounter, driver);
        CommonUtils.appendTextToFile(screenPath + imageCounter + ".html", getPageSource(driver));
      } catch (Exception e) {
        log(
            "onException",
            "driver has no ability to catch screenshot or html source - driver may died",
            false);
      }

      String exception =
          escapeHtml(
              result.getThrowable().toString()
                  + "\n"
                  + ExceptionUtils.getStackTrace(result.getThrowable()));

      StringBuilder builder = new StringBuilder();
      builder.append(
          "<tr class=\"error\"><td>error</td><td><pre>"
              + exception
              + "</pre></td><td> <br/><a href='screenshots/screenshot"
              + imageCounter
              + ".png'>Screenshot</a><br/><a href='screenshots/screenshot"
              + imageCounter
              + ".html'>HTML Source</a></td></tr>");
      CommonUtils.appendTextToFile(logPath, builder.toString());
      logJSError(driver);
      onTestSuccess(result);
    }
  }