Vivek Rao
Vivek Rao

Reputation: 219

Error display unable to delete the file chromedriver.exe while running a Selenium project in Visual studio

I am running a Selenium C# project through Visual studio and suddenly encountered an error

Access to the path 'c:\users\documents\visual studio 2017\Project\SeleniumTestProject\SeleniumTestProject\bin\Debug\chromedriver.exe' is denied.

I removed the readonly attribute for the folder but still get this error. Can anyone please suggest me what could be wrong and solution for the same.

Upvotes: 18

Views: 52118

Answers (11)

Awais Imran
Awais Imran

Reputation: 99

First kill the driver which remain opened in back ground in last failed session run. Kill it by using following command in cmd.

taskkill /f /im chromedriver.exe

Now, delete chrome.exe file from bin folder

Upvotes: 1

iluvautomating
iluvautomating

Reputation: 1

I tried the command taskkill /f /im chromedriver.exe on the command line and my test ran smoothly. But I needed a way to run this every time before a test run via Visual Studio. So I put it in Project > Properties > Build Events > Pre-build. When I ran the test, I got an error:

The command taskkill /f /im chromedriver.exe exited with code 128. The process chromedriver.exenot found.

So I used this instead: taskkill /f /fi "pid gt 0" /im chromedriver.exe. It works like a charm!

Upvotes: 0

Rohit
Rohit

Reputation: 91

Deleted the chrome driver exe from command prompt

Launch command prompt and enter "taskkill /f /im chromedriver.exe" command. Then rebuild the code again.

Upvotes: 4

Mohamed Mousa
Mohamed Mousa

Reputation: 1

Just you can cut chromeDriver.exe from debug folder and paste it to another place, then rebuild the project again

Upvotes: 0

evance masemola
evance masemola

Reputation: 11

My solution was to remove the Selenium.Chrome.WebDriver fixed version that I installed as part of my Nuget package and then cleaned my solution.

enter image description here

Upvotes: 1

Dilip Meghwal
Dilip Meghwal

Reputation: 632

End the chrome driver process from task manager.

Upvotes: 1

Gobena
Gobena

Reputation: 491

Just worked when I killed the chrome driver exe from command prompt

  • Launch command prompt and enter "taskkill /f /im chromedriver.exe"

  • Clean your solution

Upvotes: 49

MHD RASIM
MHD RASIM

Reputation: 21

'c:\users\documents\visual studio 2017\Project\SeleniumTestProject\SeleniumTestProject\bin\Debug\chromedriver.exe'

First end the process of chromedriver.exe from Task Manger, then Delete the chromedriver.exe from your project bin file and check whether Selenium.WebDriver.ChromeDriver package installed or not, If it's not installed you should installSelenium.WebDriver.ChromeDriver package from "NuGet Package Manager"..and rebuild , otherwise rebuild the project directly...

Upvotes: 2

Aniket Deshpande
Aniket Deshpande

Reputation: 141

I solved it by shutting down the ChromeDriver correctly. I used: IWebDriver.Dispose() for quitting the ChromeDriver process

In your case, after your test completes, there should be a chromedriver.exe in your Task Manager which does not quit until you manually "End Process" it. However, if you use IWebDriver.Dispose(), it kills the process. And now, since the chromedriver.exe is no longer in use, the "Access denied" problem also goes away.

Hope this solves your problem. Reference: https://stackoverflow.com/a/44126143/1785144

Upvotes: 14

Suban
Suban

Reputation: 15

Hi I ended up downgrading my Chrome version from 58 to 57 whilst using the chromedriver nuget package 2.29 and it seems to be working ok now. haven't workedd out why yet though

Upvotes: 0

Suban
Suban

Reputation: 15

I am experiencing the same issue using visual studio 2017. I'm having to delete the chromdriver process via task manager, clean the solution and then build and start the test. I am also using a driver.Quit() method as my tear down

Upvotes: 0

Related Questions