Skip to content

[🐛 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

Closed
ssrmm opened this issue Sep 13, 2023 · 38 comments
Labels
C-rust Rust code is mostly Selenium Manager I-defect Something is not working as intended
Milestone

Comments

@ssrmm
Copy link

ssrmm commented Sep 13, 2023

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

@ssrmm ssrmm added I-defect Something is not working as intended A-needs-triaging A Selenium member will evaluate this soon! labels Sep 13, 2023
@github-actions
Copy link

@ssrmm, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol diemol removed the A-needs-triaging A Selenium member will evaluate this soon! label Sep 13, 2023
@diemol
Copy link
Member

diemol commented Sep 13, 2023

@bonigarcia @titusfortner
How could we handle cases like this one? They still need to use MSEdgeDriver to automate the WebView2 instance, but they do not need to download Edge. They also do not need to pass the binary location because the app is already running, and they connect to the debugger address.

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?

@titusfortner
Copy link
Member

I agree Rust should ignore browser checking if that's the browser name. (return empty string?)

The question is whether the driver ignores binary property if an empty string is passed by the capabilities. In which case we'd also need to update the bindings.

@titusfortner titusfortner added the C-rust Rust code is mostly Selenium Manager label Sep 13, 2023
@diemol
Copy link
Member

diemol commented Sep 13, 2023

SM also needs to ignore the binary path because if it is present and the browser name is webview2, it won't be the Edge binary.

@titusfortner
Copy link
Member

Do you mean the Selenium Manager classes in the bindings?

@bonigarcia
Copy link
Member

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 browserVersion is informed, and the Rust logic cannot download Edge (since it is not implemented yet).

I think the easy solution for this issue is to remove the option browserVersion:

var options = new EdgeOptions { DebuggerAddress = "localhost:12345" };

Alternatively, there is an argument to avoid browser downloads in Selenium Manager. It can be enabled by setting an environment variable SE_AVOID_BROWSER_DOWNLOAD=true.

Regarding the webview2 part, I was not aware of that. I have just checked on my local Windows machine, and there is a WebView binary on C:\Program Files (x86)\Microsoft\EdgeWebView\Application\116.0.1938.76\msedge.exe. Should this path be returned as browser-path by SM when the browser is webview2?

@ssrmm
Copy link
Author

ssrmm commented Sep 14, 2023

I think the easy solution for this issue is to remove the option browserVersion

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:

Unhandled exception. OpenQA.Selenium.WebDriverException: unknown error: cannot connect to microsoft edge at localhost:12345
from session not created: This version of Microsoft Edge WebDriver only supports Microsoft Edge version 113
Current browser version is 116.0.1938.81
   at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
   at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
   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)

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 };

Regarding the webview2 part, I was not aware of that. I have just checked on my local Windows machine, and there is a WebView binary on C:\Program Files (x86)\Microsoft\EdgeWebView\Application\116.0.1938.76\msedge.exe. Should this path be returned as browser-path by SM when the browser is webview2?

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.

@titusfortner
Copy link
Member

@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"}}}}
This errored on my not having anything running on port 9222, not on an invalid location of binary

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.

@titusfortner
Copy link
Member

(which means that the code in the bindings should be fine as-is)

@simhachalamnaidu
Copy link

What is the conclusion of this issue? i am also having the similar issue with version="4.13.1"

EdgeOptions edgeOptions = new();
edgeOptions.UseWebView = true;
edgeOptions.BinaryLocation = new FileInfo(Path.Combine(WebDriverCusmomParams.WpfMockPath, WpfMockExe)).FullName;
edgeOptions.SetLoggingPreference("performance", LogLevel.All);
return new EdgeDriver(edgeOptions);

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"
Standard Output >>
{
"logs": [
{
"level": "ERROR",
"timestamp": 1696598838,
"message": "Invalid browser name: webview2"
}
],
"result": {
"code": 65,
"message": "Invalid browser name: webview2",
"driver_path": "",
"browser_path": ""
}
}

@titusfortner titusfortner added this to the 4.15 milestone Oct 7, 2023
@bonigarcia
Copy link
Member

@simhachalamnaidu As suggested by @titusfortner, I am going to include the logic required in Selenium Manager to treat webview2 like Microsoft Edge for getting the driver but returning an empty string for the location of the browser instead of trying to obtain it. This change, hopefully, will be available for the next Selenium version.

@ssrmm
Copy link
Author

ssrmm commented Oct 13, 2023

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 selenium-4.14.0 tag and the changelog mentions WebView2 support. One the other hand this issue is still open and stating 4.15 as the target milestone. When manually testing with the 4.14.0 NuGet I still get Invalid browser name: webview2.

@titusfortner
Copy link
Member

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?

@ssrmm
Copy link
Author

ssrmm commented Oct 16, 2023

It looks basically the same as before the release:

Unhandled exception. 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: selenium-manager\windows\selenium-manager.exe  --browser "webview2" --output json
 ---> OpenQA.Selenium.WebDriverException: Selenium Manager process exited abnormally with 65 code: selenium-manager\windows\selenium-manager.exe  --browser "webview2" --output json
Standard Output >>
{
  "logs": [
    {
      "level": "ERROR",
      "timestamp": 1697447237,
      "message": "Invalid browser name: webview2"
    }
  ],
  "result": {
    "code": 65,
    "message": "Invalid browser name: webview2",
    "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)

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);

@titusfortner
Copy link
Member

Try with 4.14.1
There was an issue with 4.14.0

@bonigarcia
Copy link
Member

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:

boni@slimbook:~/.nuget/packages/selenium.webdriver/4.14.1/manager/linux$ ./selenium-manager --browser webview2 --debug
DEBUG	msedgedriver not found in PATH
DEBUG	webview2 detected at /usr/bin/microsoft-edge
DEBUG	Running command: /usr/bin/microsoft-edge --version
DEBUG	Output: "Microsoft Edge 118.0.2088.46 "
DEBUG	Detected browser: webview2 118.0.2088.46
DEBUG	Required driver: msedgedriver 118.0.2088.46
DEBUG	msedgedriver 118.0.2088.46 already in the cache
INFO	Driver path: /home/boni/.cache/selenium/msedgedriver/linux64/118.0.2088.46/msedgedriver

@titusfortner As you can see, as requested, SM returns an empty string for the browser's location when the browser is webview2:

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.

Nevertheless, it seems the bindings are not prepared to use WebView2. I tried the following test in .Net and Selenium 4.14.1:

using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;

namespace SeleniumDocs.Browsers
{
    [TestClass]
    public class EdgeTest
    {
        private EdgeDriver driver;

        [TestCleanup]
        public void Cleanup()
        {
            driver.Quit();
        }

        [TestMethod]
        public void BasicOptions()
        {
            var options = new EdgeOptions { UseWebView = true };
            driver = new EdgeDriver(options);
        }

    }
}

And it fails as follows:

  Failed BasicOptions [357 ms]
  Error Message:
   Test method SeleniumDocs.Browsers.EdgeTest.BasicOptions threw exception:
System.NotImplementedException: unknown command: must specify a binary when using WebView2 launch
TestCleanup method SeleniumDocs.Browsers.EdgeTest.Cleanup threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..
  Stack Trace:
      at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
   at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
   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 SeleniumDocs.Browsers.EdgeTest.BasicOptions() in C:\Users\boni\Documents\dev\seleniumhq.github.io\examples\dotnet\SeleniumDocs\Browsers\EdgeTest.cs:line 26

TestCleanup Stack Trace
   at SeleniumDocs.Browsers.EdgeTest.Cleanup() in C:\Users\boni\Documents\dev\seleniumhq.github.io\examples\dotnet\SeleniumDocs\Browsers\EdgeTest.cs:line 19


Failed!  - Failed:     1, Passed:     0, Skipped:     0, Total:     1, Duration: 369 ms

I also tried the Java bindings (version 4.14.1) with similar result:

EdgeOptions options = new EdgeOptions();
options.useWebView(true);
driver = new EdgeDriver(options);

Internally, SM works as expected:

Oct 16, 2023 2:37:46 PM org.openqa.selenium.manager.SeleniumManager getBinary
FINE: Selenium Manager binary found at: C:\Users\boni\AppData\Local\Temp\selenium-manager80037639563008025714261898269912\selenium-manager.exe
Oct 16, 2023 2:37:46 PM org.openqa.selenium.manager.SeleniumManager runCommand
FINE: Executing Process: [--browser, webview2, --output, json, --debug]
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: msedgedriver not found in PATH
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: webview2 detected at C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Running command: wmic datafile where name='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe' get Version /value
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Output: "\r\r\n\r\r\nVersion=118.0.2088.46\r\r\n\r\r\n\r\r\n\r"
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Detected browser: webview2 118.0.2088.46
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Reading msedgedriver version from https://msedgedriver.azureedge.net/LATEST_RELEASE_118_WINDOWS
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Required driver: msedgedriver 118.0.2088.46
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: msedgedriver 118.0.2088.46 already in the cache
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Driver path: C:\Users\boni\.cache\selenium\msedgedriver\win64\118.0.2088.46\msedgedriver.exe
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager getDriverPath
FINE: Using driver at location: C:\Users\boni\.cache\selenium\msedgedriver\win64\118.0.2088.46\msedgedriver.exe, browser at location 

But the test fails as follows:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 404. Message: unknown command: must specify a binary when using WebView2 launch 
Host info: host: 'DESKTOP-2KE0PTJ', ip: '192.168.56.1'
Build info: version: '4.14.1', revision: '03f8ede370'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.15'
Driver info: org.openqa.selenium.edge.EdgeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: webview2, ms:edgeOptions: {args: [], binary: , extensions: []}}]}]

@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?

@titusfortner
Copy link
Member

Ah, the bindings are putting the empty string into the options instead of "null" and that's throwing the driver?

@bonigarcia
Copy link
Member

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.

@titusfortner
Copy link
Member

Oh, if you can get it reproduced in Java, can you turn on logging so I can verify that's the issue? Thanks.

@bonigarcia
Copy link
Member

@titusfortner I already did. I put the logs captured in the Java bindings above:

Internally, SM works as expected:

Oct 16, 2023 2:37:46 PM org.openqa.selenium.manager.SeleniumManager getBinary
FINE: Selenium Manager binary found at: C:\Users\boni\AppData\Local\Temp\selenium-manager80037639563008025714261898269912\selenium-manager.exe
Oct 16, 2023 2:37:46 PM org.openqa.selenium.manager.SeleniumManager runCommand
FINE: Executing Process: [--browser, webview2, --output, json, --debug]
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: msedgedriver not found in PATH
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: webview2 detected at C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Running command: wmic datafile where name='C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe' get Version /value
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Output: "\r\r\n\r\r\nVersion=118.0.2088.46\r\r\n\r\r\n\r\r\n\r"
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Detected browser: webview2 118.0.2088.46
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Reading msedgedriver version from https://msedgedriver.azureedge.net/LATEST_RELEASE_118_WINDOWS
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Required driver: msedgedriver 118.0.2088.46
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: msedgedriver 118.0.2088.46 already in the cache
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager lambda$runCommand$1
FINE: Driver path: C:\Users\boni\.cache\selenium\msedgedriver\win64\118.0.2088.46\msedgedriver.exe
Oct 16, 2023 2:37:47 PM org.openqa.selenium.manager.SeleniumManager getDriverPath
FINE: Using driver at location: C:\Users\boni\.cache\selenium\msedgedriver\win64\118.0.2088.46\msedgedriver.exe, browser at location 

@titusfortner
Copy link
Member

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.

@bonigarcia
Copy link
Member

I believe I already reported that, at the end of this snippet:

But the test fails as follows:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 404. Message: unknown command: must specify a binary when using WebView2 launch 
Host info: host: 'DESKTOP-2KE0PTJ', ip: '192.168.56.1'
Build info: version: '4.14.1', revision: '03f8ede370'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.15'
Driver info: org.openqa.selenium.edge.EdgeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: webview2, ms:edgeOptions: {args: [], binary: , extensions: []}}]}]

@titusfortner
Copy link
Member

Ok, fixed in all the bindings

@ssrmm
Copy link
Author

ssrmm commented Oct 16, 2023

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

@titusfortner
Copy link
Member

Oh, I forgot to wait for 4.14.1 to make sure it was a real problem. oh well, this shouldn't break anything. 😄

@simhachalamnaidu
Copy link

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?

@titusfortner
Copy link
Member

Are you providing the location and selenium isn't using it, or do you want selenium to figure out the location?

@simhachalamnaidu
Copy link

@titusfortner if you are talking about the binary location, yes we've provided the location as below code.

EdgeOptions edgeOptions = new();
edgeOptions.UseWebView = true;
edgeOptions.BinaryLocation = new FileInfo(Path.Combine(WebDriverCusmomParams.WpfMockPath, WpfMockExe)).FullName;
edgeOptions.SetLoggingPreference("performance", LogLevel.All);
return new EdgeDriver(edgeOptions);

@titusfortner
Copy link
Member

@bonigarcia does webview return the browser location that gets passed in now?

@bonigarcia
Copy link
Member

@bonigarcia does webview return the browser location that gets passed in now?

When using webview2 as a browser, in the latest version of Selenium Manager, it locates the WebView2 path (in Windows). So, theoretically, it is not required to pass the browser binary path. I think that if the browser path is specified as options, that value should be returned by Selenium Manager as the browser path. But I would need to see the Selenium Manager to see what is happening.

@titusfortner
Copy link
Member

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?

@simhachalamnaidu
Copy link

Any Updates?

@titusfortner
Copy link
Member

Let me re-open it so I can remember to take a look at it again.

@titusfortner titusfortner reopened this Nov 8, 2023
@simhachalamnaidu
Copy link

Any feedback on this topic?

@titusfortner titusfortner modified the milestones: 4.15, 4.16 Nov 25, 2023
@titusfortner
Copy link
Member

@bonigarcia ok, yeah, something isn't right in the browser path as you can see here:

This is selenium-manager built from trunk:

.\selenium-manager.exe --browser webview2 --browser-path "C:/Program Files (x86)/Microsoft/EdgeWebView/Application/119.0.2151.72/msedge.exe" --output json --debug

gives this:

{
  "logs": [
    {
      "level": "DEBUG",
      "timestamp": 1701042096,
      "message": "msedgedriver not found in PATH"
    },
    {
      "level": "DEBUG",
      "timestamp": 1701042096,
      "message": "Running command: REG QUERY HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\EdgeUpdate\\Clients\\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5} /v pv"
    },
    {
      "level": "DEBUG",
      "timestamp": 1701042096,
      "message": "Output: \"\\r\\nHKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\WOW6432Node\\\\Microsoft\\\\EdgeUpdate\\\\Clients\\\\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}\\r\\n    pv    REG_SZ    119.0.2151.72\\r\\n\""
    },
    {
      "level": "DEBUG",
      "timestamp": 1701042096,
      "message": "Detected browser: webview2 119.0.2151.72"
    },
    {
      "level": "DEBUG",
      "timestamp": 1701042096,
      "message": "Required driver: msedgedriver 119.0.2151.72"
    },
    {
      "level": "DEBUG",
      "timestamp": 1701042096,
      "message": "msedgedriver 119.0.2151.72 already in the cache"
    },
    {
      "level": "INFO",
      "timestamp": 1701042096,
      "message": "Driver path: C:\\Users\\titusfortner\\.cache\\selenium\\msedgedriver\\win64\\119.0.2151.72\\msedgedriver.exe"
    },
    {
      "level": "INFO",
      "timestamp": 1701042096,
      "message": "Browser path: C:/Program Files (x86)/Microsoft/EdgeWebView/Application/119.0.2151.72/msedge.exe\\119.0.2151.72\\msedge.exe"
    }
  ],
  "result": {
    "code": 0,
    "message": "C:\\Users\\titusfortner\\.cache\\selenium\\msedgedriver\\win64\\119.0.2151.72\\msedgedriver.exe",
    "driver_path": "C:\\Users\\titusfortner\\.cache\\selenium\\msedgedriver\\win64\\119.0.2151.72\\msedgedriver.exe",
    "browser_path": "C:/Program Files (x86)/Microsoft/EdgeWebView/Application/119.0.2151.72/msedge.exe\\119.0.2151.72\\msedge.exe"
  }
}

@bonigarcia
Copy link
Member

@titusfortner Indeed, there is a bug when browser path is set for WebView2, thanks for checking. PR #13204 should fix it.

@titusfortner
Copy link
Member

Merged. Thanks!

Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-rust Rust code is mostly Selenium Manager I-defect Something is not working as intended
Projects
None yet
Development

No branches or pull requests

5 participants