4

I get this error about 50% of the time on our TFS build server:

Exception Message: Access to the path 'C:\Builds\5673\Company\QA_Web_Tests\bin\WebDrivers\chromedriver.exe' is denied. (type UnauthorizedAccessException)
Exception Stack Trace:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalDelete(String path, Boolean checkHost)
   at Microsoft.TeamFoundation.Common.FileSpec.DeleteFile(String path, Boolean throwExceptionOnFailure)
   at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String path)
   at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryInternal(String path)
   at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectory(String path, Boolean recursive)
   at Microsoft.TeamFoundation.Build.Workflow.Activities.DeleteDirectory.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

It's a 4-core processor with parallel testing (via MSTest) enabled.

One workaround is to reboot the server between builds. But that would be onerous when we want to run our tests multiple times per day.

Has anyone else run into this? Do you know a fix? Thanks.

Here's my clean up method:

public void Cleanup()
{
    WebDriver.Quit();
    Console.WriteLine(@"[console] TEST END. Datetime: " + DateTime.Now);
    _stopWatch.Stop();
    Console.WriteLine(@"[console] TEST DURATION: " + _stopWatch.Elapsed);
}
Aaron
  • 2,154
  • 5
  • 29
  • 42

1 Answers1

1

The problem is that your tests start up the webdriver, but don't shut it down.

The best solution would be to not run UI tests from a build -- UI testing should happen post-deployment, and ideally is tied to MTM test cases, or as a post-release action. MTM/Lab management is designed specifically with UI testing in mind, and would be a far more appropriate tool for the job.

The fix to your specific problem would be to change your tests so that the web driver is correctly shut down as a post-test action. The exact mechanism by which you accomplish this is up to you!

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • Thanks for the reply; however, that's not the issue in this case. I have a clean up method that does a .Quit(). I'll include the method in the body of my question above. Also, the UI tests do run after the environment is fully deployed, so that's not an issue either. The tests build is *just* running tests. – Aaron Oct 28 '14 at 17:54