-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[🐛 Bug]: Testing WebView2 with automatic download of the Edge WebDriver no longer works #12738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ssrmm, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
@bonigarcia @titusfortner One option would be to only return the MSEdgeDriver path and ignore checking the browser part when the browser name is "WebView2". What do you think? |
I agree Rust should ignore browser checking if that's the browser name. (return empty string?) The question is whether the driver ignores |
SM also needs to ignore the |
Do you mean the Selenium Manager classes in the bindings? |
I started to work on the automated management of Edge, but it is currently in development (which is easy for Windows, BTW). I believe the error in this issue happens since the option I think the easy solution for this issue is to remove the option
Alternatively, there is an argument to avoid browser downloads in Selenium Manager. It can be enabled by setting an environment variable Regarding the |
Not entirely. That works only if the Edge installed on the system has the same version as the WebView2 runtime. As I alluded to above, there might be various reasons why that is not the case (i.e. WSUS/GPOs determining the Edge version but WebView2 being controlled by the test). If the versions differ, you get this:
For now our workaround is to stay on 4.11. Generally I feel it would make most sense if the original approach worked again, because it best expresses the actual intent: var options = new EdgeOptions { DebuggerAddress = "localhost:12345", UseWebView = true };
Do note though that WebView may not actually be installed system wide. An application may use Fixed Version runtime distribution mode where the whole WebView is bundled with the application. It's not the distribution mode we use for our application, but since you presumably want to support the general case it might be something that you need to consider. |
@ssrmm setting browser version is the wrong fix. We want it to work like it has been in the MS example I did a quick test and it does not look like the edge driver parses the binary value if a debugger address is specified 2023-09-14 11:29:17 DEBUG Selenium [:command] >>> http://127.0.0.1:9515/session | {"capabilities":{"alwaysMatch":{"browserName":"webview2","ms:edgeOptions":{"binary":"invalid location","debuggerAddress":"localhost:9222"}}}} So @bonigarcia I think all SM needs to treat webview2 like MicrosoftEdge for the purposes of getting the driver, but it should return an empty string for the location of the browser instead of trying to obtain it. |
(which means that the code in the bindings should be fine as-is) |
What is the conclusion of this issue? i am also having the similar issue with version="4.13.1" EdgeOptions edgeOptions = new(); OpenQA.Selenium.NoSuchDriverException: Unable to obtain webview2 using Selenium Manager; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location ---> OpenQA.Selenium.WebDriverException: Error starting process: D:\a\1\K8SAppService_CI\iTest\selenium-manager/windows/selenium-manager.exe --browser "webview2" --output json --browser-path "D:\a\1\K8SAppService_CI\MockWPF\rcm.Cloud.mgr.wpfmock.exe" ---> OpenQA.Selenium.WebDriverException: Selenium Manager process exited abnormally with 65 code: D:\a\1\K8SAppService_CI\iTest\selenium-manager/windows/selenium-manager.exe --browser "webview2" --output json --browser-path "D:\a\1\K8SAppService_CI\MockWPF\rcm.Cloud.mgr.wpfmock.exe" |
@simhachalamnaidu As suggested by @titusfortner, I am going to include the logic required in Selenium Manager to treat |
I'm a bit confused right now, is this intended to be fixed in the 4.14 release or not? One the one hand the merge-commit of the linked PR is included in the |
It was finished earlier than expected and merged just before 4.14 was released, so this should be working. Can you provide the stack trace? |
It looks basically the same as before the release:
The corresponding code is again the one from the MS documentation: var options = new EdgeOptions { DebuggerAddress = "localhost:12345", UseWebView = true };
using var driver = new EdgeDriver(options); |
Try with 4.14.1 |
I have confirmed that Selenium Manager 0.4.14 (i.e., the release that supports WebView2) is shipped with Selenium 4.14.1 in .Net:
@titusfortner As you can see, as requested, SM returns an empty string for the browser's location when the browser is
Nevertheless, it seems the bindings are not prepared to use WebView2. I tried the following test in .Net and Selenium 4.14.1:
And it fails as follows:
I also tried the Java bindings (version 4.14.1) with similar result:
Internally, SM works as expected:
But the test fails as follows:
@titusfortner I suppose the bindings should be able to start WebView2 without the browser binary path (maybe like they did before SM passed the browser binary path). Is that right? |
Ah, the bindings are putting the empty string into the options instead of "null" and that's throwing the driver? |
I don't know the internals of the bindings about that. |
Oh, if you can get it reproduced in Java, can you turn on logging so I can verify that's the issue? Thanks. |
@titusfortner I already did. I put the logs captured in the Java bindings above:
|
I want to see the logs of what capabilities are getting sent to the driver after Selenium Manager is done. I suspect it's an empty string for the binary path, but just want to verify that's where it is stuck. |
I believe I already reported that, at the end of this snippet:
|
Ok, fixed in all the bindings |
Thanks, 4.14.1 seems to be working for me now. There is still a problem with the driver being downloaded in the wrong version if the installed versions of Edge and the WebView2 runtime differ, but I'll open a separate issue for that. Edit: Issue now created: #12958 |
Oh, I forgot to wait for 4.14.1 to make sure it was a real problem. oh well, this shouldn't break anything. 😄 |
hmm.. with 4.14.1 i am getting this error now : System.NotImplementedException: unknown command: must specify a binary when using WebView2 launch Any workaround for this or we need to wait for next version? |
Are you providing the location and selenium isn't using it, or do you want selenium to figure out the location? |
@titusfortner if you are talking about the binary location, yes we've provided the location as below code. EdgeOptions edgeOptions = new(); |
@bonigarcia does webview return the browser location that gets passed in now? |
When using |
I'm wondering if my previous fix ends up resulting in the bindings overwriting the binary path when Selenium Manager returns an empty and/or null value. If SM passes back the binary location, then the bindings will automatically send it on to the driver and it should all be correct? |
Any Updates? |
Let me re-open it so I can remember to take a look at it again. |
Any feedback on this topic? |
@bonigarcia ok, yeah, something isn't right in the browser path as you can see here: This is selenium-manager built from trunk:
gives this:
|
@titusfortner Indeed, there is a bug when browser path is set for WebView2, thanks for checking. PR #13204 should fix it. |
Merged. Thanks! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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:This broke with (I believe) version 4.9, producing the following error:
Assuming at the time that this was an intentional change, we removed the
UseWebView
property. Instead we addedBrowserVersion
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.This however now also broke with Selenium 4.12.* and produces the following error:
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
The text was updated successfully, but these errors were encountered: