selenium: [π Bug]: Testing WebView2 with automatic download of the Edge WebDriver no longer works
What happened?
We are using Selenium for testing a WebView2 instance from C# code. Originally we used the below code to create the EdgeDriver
, as per Microsoft documentation:
using OpenQA.Selenium.Edge;
var options = new EdgeOptions { DebuggerAddress = "localhost:12345", UseWebView = true };
using var driver = new EdgeDriver(options);
This broke with (I believe) version 4.9, producing the following error:
Unhandled exception. OpenQA.Selenium.WebDriverException: Unable to locate driver with path: msedgedriver.exe, for more information on how to install drivers see https://www.selenium.dev/documentation/webdriver/getting_started/instal
l_drivers/
---> OpenQA.Selenium.WebDriverException: Invalid response from process (code 65): selenium-manager/windows/selenium-manager.exe --browser "webview2" --output json
Invalid browser name: webview2
at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
at OpenQA.Selenium.SeleniumManager.DriverPath(DriverOptions options)
at OpenQA.Selenium.DriverFinder.VerifyDriverServicePath(DriverService service, DriverOptions options)
--- End of inner exception stack trace ---
at OpenQA.Selenium.DriverFinder.VerifyDriverServicePath(DriverService service, DriverOptions options)
at OpenQA.Selenium.Edge.EdgeDriverService.CreateDefaultService(EdgeOptions options)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeOptions options)
at Program.<Main>$(String[] args)
Assuming at the time that this was an intentional change, we removed the UseWebView
property. Instead we added BrowserVersion
to avoid Selenium picking up the version of the installed Edge browser (which might differ from the used WebView2 version for various reasons) as the basis for the Edge WebDriver version it downloads.
using OpenQA.Selenium.Edge;
var options = new EdgeOptions { DebuggerAddress = "localhost:12345", BrowserVersion = "116" };
using var driver = new EdgeDriver(options);
This however now also broke with Selenium 4.12.* and produces the following error:
Unhandled exception. OpenQA.Selenium.NoSuchDriverException: Unable to obtain MicrosoftEdge using Selenium Manager; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/error
s/driver_location
---> OpenQA.Selenium.WebDriverException: Error starting process: selenium-manager/windows/selenium-manager.exe --browser "MicrosoftEdge" --output json
--browser-version 116
---> OpenQA.Selenium.WebDriverException: Selenium Manager process exited abnormally with 65 code: selenium-manager/windows/selenium-manager.exe --brows
er "MicrosoftEdge" --output json --browser-version 116
Error Output >>
Standard Output >>
{
"logs": [
{
"level": "ERROR",
"timestamp": 1694621742,
"message": "edge 116 cannot be downloaded"
}
],
"result": {
"code": 65,
"message": "edge 116 cannot be downloaded",
"driver_path": "",
"browser_path": ""
}
}
at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
--- End of inner exception stack trace ---
at OpenQA.Selenium.SeleniumManager.RunCommand(String fileName, String arguments)
at OpenQA.Selenium.SeleniumManager.DriverPath(DriverOptions options)
at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
--- End of inner exception stack trace ---
at OpenQA.Selenium.DriverFinder.FullPath(DriverOptions options)
at OpenQA.Selenium.Chromium.ChromiumDriver.GenerateDriverServiceCommandExecutor(DriverService service, DriverOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options)
at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeOptions options)
at Program.<Main>$(String[] args)
How can we reproduce the issue?
See code examples in the above description.
Relevant log output
According to the documentation there is no logger for .NET, so I am not sure where to get logs, aside from the exception stack traces above.
Operating System
Windows 10, Windows 11
Selenium version
4.12.4
What are the browser(s) and version(s) where you see this issue?
Edge WebView2 116
What are the browser driver(s) and version(s) where you see this issue?
Whichever one Selenium downloads (or doesnβt in this case)
Are you using Selenium Grid?
No
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 38 (27 by maintainers)
Commits related to this issue
- [dotnet] do not set binary as empty string (#12738) — committed to SeleniumHQ/selenium by titusfortner 8 months ago
- [java] do not set browser binary if it is an empty string (#12738) — committed to SeleniumHQ/selenium by titusfortner 8 months ago
- [py] do not set browser binary in selenium manager if it is an empty string (#12738) — committed to SeleniumHQ/selenium by titusfortner 8 months ago
- [rb] do not set browser binary in selenium manager if it is an empty string (#12738) — committed to SeleniumHQ/selenium by titusfortner 8 months ago
- [dotnet] do not set binary as empty string (#12738) — committed to aguspe/selenium by titusfortner 8 months ago
- [java] do not set browser binary if it is an empty string (#12738) — committed to aguspe/selenium by titusfortner 8 months ago
- [py] do not set browser binary in selenium manager if it is an empty string (#12738) — committed to aguspe/selenium by titusfortner 8 months ago
- [rb] do not set browser binary in selenium manager if it is an empty string (#12738) — committed to aguspe/selenium by titusfortner 8 months ago
I believe I already reported that, at the end of this snippet: