title: Selenium Test case stop by getting error on after method
body: <p>I have a project where I use Testng and use extend report for reporting.I have 64 total test case but when 24 number test case, when running my after method, shows error and stop the execution.Can we continue execution?</p>
  
  <blockquote>
    <p>is there Any suggestion how can I over come from stop execution </p>
  </blockquote>
  
  <p>Here is my after method class</p>
  
  <pre><code>    @AfterMethod
  public void setTestResult(ITestResult result) throws IOException {
  
      String screenShot = CaptureScreenShot.captureScreen(wd, CaptureScreenShot.generateFileName(result));
  
      if (result.getStatus() == ITestResult.FAILURE) {
          test.log(Status.FAIL, result.getName());
          test.log(Status.FAIL,result.getThrowable());
          test.fail("Screen Shot : " + test.addScreenCaptureFromPath(screenShot));
      } else if (result.getStatus() == ITestResult.SUCCESS) {
          test.log(Status.PASS, result.getName());
          test.pass("Screen Shot : " + test.addScreenCaptureFromPath(screenShot));
      } else if (result.getStatus() == ITestResult.SKIP) {
          test.skip("Test Case : " + result.getName() + " has been skipped");
      }
  
      extent.flush();
      wd.quit();
  }
  </code></pre>
  
  <p>Here Is my CaptureScreenShot Class</p>
  
  <pre><code>public class CaptureScreenShot {
  private static final DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd SSS");
  
  public static String captureScreen(WebDriver driver, String screenName) throws IOException{
  
      TakesScreenshot screen = (TakesScreenshot) driver;
      File src = screen.getScreenshotAs(OutputType.FILE);
  
      String dest ="C:/xampp//htdocs/Automation_report/Test-ScreenShots"+screenName+".png";
  
      File target = new File(dest);
      FileUtils.copyFile(src, target);
  
      return dest;
  }
  
  public static String generateFileName(ITestResult result){
      Date date = new Date();
      String fileName = result.getName()+ "_" + dateFormat.format(date);
      return fileName;
  
  }
  }
  </code></pre>
  
  <p>I am writing test case This way</p>
  
  <pre><code>@test
  public void DetailsPageRedirectToPartnerSite_VRBO() throws InterruptedException {
      test = extent.createTest("Details PageRedirecToPartner Site");
  
  }
  </code></pre>
  
  <blockquote>
    <p>I am getting following error</p>
  </blockquote>
  
  <pre><code>java.nio.channels.ClosedByInterruptException
  at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:202)
  at sun.nio.ch.FileChannelImpl.size(FileChannelImpl.java:315)
  at org.apache.commons.io.FileUtils.doCopyFile(FileUtils.java:1145)
  at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1088)
  at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1040)
  at vrs.CaptureScreenShot.captureScreen(CaptureScreenShot.java:25)
  at vrs.BedroomvillasProduction.setTestResult(BedroomvillasProduction.java:2320)
  at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
  at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
  at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
  at org.testng.internal.Invoker.invokeMethod(Invoker.java:786)
  at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
  at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
  at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
  at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
  at org.testng.TestRunner.privateRun(TestRunner.java:767)
  at org.testng.TestRunner.run(TestRunner.java:617)
  at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
  at org.testng.SuiteRunner.access$000(SuiteRunner.java:37)
  at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:368)
  at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
  </code></pre>