Seleniun C# using MS Edge webdriver: The msedgedriver.exe file does not exist....

moondaddy 916 Reputation points
2021-02-17T04:01:38.99+00:00

I see a lot of posts about this problem and none of the answers work for me. Using this MS link to create a sample project:
https://learn.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=c-sharp

Here's what I have and did:

Edge Version 88.0.705.68 (Official build) (64-bit)

I downloaded the correct driver: Version 88.0.705.68, msedgedriver.exe
to: D:\Archive\Downloads\EdgeDriver\Version 88.0.705.68 (nothing to install, just run it)
68911-image.png

Choose a WebDriver language binding
The Microsoft Edge team recommends: Install-Package Selenium.WebDriver -Version 4.0.0-alpha07

Selenium Tools for Microsoft Edge/Before you Begin:
"If you are able to upgrade to Selenium 4 Alpha, there is no need to use this package as Selenium should already have everything you need built in!"
I think i did this in the previous step

Add the Microsoft.Edge.SeleniumTools and Selenium.WebDriver packages to your .NET project using the NuGet CLI or Visual Studio.

"Add the Microsoft.Edge.SeleniumTools and Selenium.WebDriver packages to your .NET project using the NuGet CLI or Visual Studio." done

and when I run this code:

var options = new EdgeOptions();  
options.UseChromium = true;  
var driver = new EdgeDriver(options);  

I get this error:

OpenQA.Selenium.DriverServiceNotFoundException  
  HResult=0x80131500  
  Message=The msedgedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/.  
  Source=WebDriver  
  StackTrace:  
   at OpenQA.Selenium.DriverService.FindDriverServiceExecutable(String executableName, Uri downloadUrl)  
   at OpenQA.Selenium.Edge.EdgeDriverService.CreateDefaultServiceFromOptions(EdgeOptions options)  
   at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeOptions options)  
   at SeleniumTest2.Program.Main(String[] args) in D:\Apps\zDeleteme\SeleniumTest2\SeleniumTest2\Program.cs:line 35  

when I search this error I find answers like this:
https://social.msdn.microsoft.com/Forums/en-US/a6749b18-12c1-4d16-bdbc-35b21adb9e7d/seleniun-c-using-ms-edge-webdriver?forum=vstest

"According to the Error Message, the WebDriver does not exist under the project path. One workaround is that you can copy the file ‘MicrosoftWebDriver.exe’ you have installed to you project path ‘…\your project name\bin\Debug\’, and then debug it again."

but I can't find MicrosoftWebDriver.exe and when I search for that its not found in the locations I see in online answers.

such as C:\Windows\SysWOW64\MicrosoftWebDriver.exe (not there)
or C:\Windows\system32\MicrosoftWebDriver.exe (not here either)

Can someone please lend a hand in sorting this out and get this up and running?

Thank you.

Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Daniel Zhang-MSFT 9,651 Reputation points
    2021-02-17T08:14:48.37+00:00

    Hi moondaddy-8531,
    Please follow the steps to see what the problem is:

    1. Using Visual Studio, add a new item to the project by right-clicking on the project -> Add Item -> Existing Item
    2. Navigate and select the your msedgedriver.exe
    3. In the msedgedriver.exe's properties page, you need to set "Copy to Output Directory" to "Copy always".

    68977-217.png
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. moondaddy 916 Reputation points
    2021-02-17T19:31:29.84+00:00

    Bingo! That was it. I spent hours on this and I see many other people have had the same problem. This screenshot was also a big help, so please add this to the MS docs to make it more clear to others.

    Thank you so much!

    0 comments No comments

  2. Tom H 1 Reputation point
    2021-07-27T11:41:01.837+00:00

    The error message I got was "The MicrosoftWebdriver.exe file does not exist in the current directory or in a directory on the PATH environment variable." You can find MicrosoftWebdriver.exe in Solution Explorer. Just copy it to one of the path.
    118209-image.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.