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);
}