Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 0.68 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why is my test leaking file descriptors?
  2. Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.11:test (default-test) on project guitest: Failure or timeout
  3. ...
  4. Process leaked file descriptors
  5.        
  6. File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
  7. File destFile = new File(...);
  8. FileUtils.copyFile(scrFile, destFile);
  9.        
  10. Runtime.getRuntime().addShutdownHook(new Thread(){
  11.     @Override
  12.     public void run(){
  13.         for (WebDriver driver : drivers.values())
  14.             driver.close();
  15.  
  16.         if (!driversInUse.isEmpty())
  17.             throw new IllegalStateException("There are still drivers in use (" + driversInUse.size() + ")");
  18.     }
  19. });