Microsoft Edge WebDriver - Unexpected error. Unknown error
Asked Answered
R

3

9

I am getting the following exception when trying to get Microsoft Edge automation to work with Selenium:

OpenQA.Selenium.WebDriverException: Unexpected error. Unknown error

I am using the Selenium.WebDriver.MicrosoftDriver NuGet package, version 17.17134.0.

My code is simply the constructor:

var driver = new EdgeDriver();

I have tried various overloads that are suggested:

var driver = new EdgeDriver(new EdgeOptions());

var driver = new EdgeDriver(pathToMicrosoftWebDriverExecutable);

No luck. I made sure that the WebDriver version from Microsoft matched the Edge version on the machine running the tests.

Is there any way I can get a more informative error message here? Note that all Selenium unit tests work as expected with both the Firefox and Chrome WebDrivers, it's only Edge that won't work.

Rosetterosewall answered 29/11, 2018 at 13:43 Comment(4)
any updates on the issue? I have same problem :/Apnea
@Apnea I was unable to resolve this issue and have had our Edge tests go stale due to it. I have not taken the time to open a support case with Microsoft, which may be the best option here. I'm surprised more people aren't having the same issue, I'm not sure why it is occurring for us.Rosetterosewall
Same issue here. I guess people just don't use Edge much, so not many devs bother to auto test in it...Placative
I'm still having the same issue much later. I tried installing developer mode as suggested below and it didn't resolve the issue either. I'm still looking for a solution.Passmore
M
2

I know you mentioned you had the same versions, but I was getting the same error myself and this is how I resolved it so hopefully this helps.

It appears that Microsoft is no longer releasing the Web Driver as a standalone version, which may be the issue. (See here for more details) Currently, Edge seems to be at version 17763, whereas the NuGet package is 17134. So what I had to do was go in and "install it as a standalone by going to Settings > Apps > Apps & features > Manage optional features." There are some alternative directions that are included in the link above.

Once that installed I pointed the driver to the location and it finally worked.

var driver = new EdgeDriver("C:\\Windows\\System32\\", edgeOptions);
Melamie answered 4/3, 2019 at 19:46 Comment(0)
K
0

I'm not sure how or why, but this worked for me, also. I was getting the pesky "Message: OpenQA.Selenium.WebDriverException : Unexpected error. Unknown error".

I followed Brian Murphy's instructions to install Microsoft Edge Driver as a Standalone by managing my optional features. I don't know where windows installed it, and I didn't need to change any of my code in C#, and my test which was previously failing at Driver = new EdgeDriver(edgeService, options);

once again started to pass.

Kathlyn answered 26/6, 2019 at 15:40 Comment(1)
What did you do to initialize the edgeService? Perhaps this is the key for yours working. I tried not specifying the c:\windows\system32 location, but that didn't work for me.Passmore
P
0

This answer doesn't necessarily solve all edge driver issues, but I was able to get past this error by downloading the specific edge driver matching the version of edge I have installed from here:

https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

In my case, I am using "88.0.705.74" of Edge so I downloaded:

https://msedgedriver.azureedge.net/88.0.705.74/edgedriver_win64.zip

Once I downloaded the driver, I unzipped it locally, but when I specify the directory in C#, it expects the file name to be "MicrosoftWebDriver.exe" instead of "msedgedriver.exe", so I renamed it accordingly:

EdgeOptions options = new EdgeOptions();
IWebDriver edgeDriver = new EdgeDriver("C:\\Users\\[username]\\Downloads\\edgedriver_win64", options);

Now, it loads the driver, I just ran into a couple other errors depending on the machine and account I was running under. I was able to get Edge to navigate to a page.

Passmore answered 25/2, 2021 at 5:31 Comment(1)
Update to this: If you download per MS's instructions you might have to use this syntax: _driver = new EdgeDriver(EdgeDriverService.CreateDefaultService(@"C:\bin\EdgeDriver", "msedgedriver.exe"), options);Canula

© 2022 - 2024 — McMap. All rights reserved.