September 21, 2021

How to fix Access to the path 'C:\Users\..\bin\Debug\chromedriver.exe' is denied. issue while using selenium

  September 21, 2021

There will be situations where we will not be able to delete the chromedriver or access it.

One such recurring scenario is when we try to update the chromedriver.

We may get an error message like mentioned below if our chromedriver version is outdated.

The browser may open for a second and closes automatically if this is the cause.

 System.InvalidOperationException: session not created: This version of ChromeDriver only supports Chrome version 91

    Current browser version is 93.0.4577.82 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe (SessionNotCreated).

We can fix this issue by updating the chromedriver to the latest version from Nuget Manager / Market Place

If we tried to build the solution again, Then comes the issue of access being denied. This happens since the old chromedriver is still running in the backend from the last run.

The error may look like this.

Severity Code Description Project File Line Suppression State

Warning Could not copy "C:\Users\..\packages\Selenium.WebDriver.ChromeDriver.93.0.4577.6300\build\..\driver\win32\chromedriver.exe" to "C:\Users\..\bin\Debug\chromedriver.exe". Beginning retry 1 in 1000ms. The process cannot access the file 'C:\Users\..\bin\Debug\chromedriver.exe' because it is being used by another process. The file is locked by: "chromedriver.exe (24288)"

We can easily fix this issue by going to the task manager and ending the task "chromedriver.exe"

If we tried to run the script multiple times with the old driver instance, there may be more than one chromedriver task

in the task manager.

Do an End task to all existing chromedrivers and try to build again. In a normal scenario, your build will get

successful and the script will get executed.


Thanks for reading How to fix Access to the path 'C:\Users\..\bin\Debug\chromedriver.exe' is denied. issue while using selenium

« Prev Post

No comments:

Post a Comment

Bookmark this website for more workarounds and issue fixes.

Verify Zip file contents without extracting using C# + Selenium

While doing automation testing, we may get a scenario where we need to download a zip file and to validate the contents inside it. One way t...