selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🐛 Bug]: DotNet WebDriver msedge(Ver:103.0.1264.77)Use EdgeOptions DebuggerAddress is 127.0.0.1:50521 Error

Open flysky2005 opened this issue 2 years ago • 5 comments

What happened?

OpenQA.Selenium.WebDriverArgumentException: invalid argument: entry 0 of 'firstMatch' is invalid from invalid argument: cannot parse capability: ms:edgeOptions from invalid argument: unrecognized msedge option: excludeSwitches 在 OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse) 在 OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) 在 OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities) 在 OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities) 在 OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout) 在 OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout) 在 XRBrowser.MainForm.CreateEdgeDriver(Boolean& isRunning))

How can we reproduce the issue?

var options = new EdgeOptions();
var debugHost = "127.0.0.1";
var debugPort = 50521;
options.DebuggerAddress = $"{debugHost}:{debugPort}";
driver = new EdgeDriver(driverService, options, TimeSpan.FromSeconds(40));

Relevant log output

OpenQA.Selenium.WebDriverArgumentException: invalid argument: entry 0 of 'firstMatch' is invalid
from invalid argument: cannot parse capability: ms:edgeOptions
from invalid argument: unrecognized msedge option: excludeSwitches
   在 OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse)
   在 OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   在 OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
   在 OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
   在 OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
   在 OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
   在 XRBrowser.MainForm.CreateEdgeDriver(Boolean& isRunning))

Operating System

Windows 11

Selenium version

Dotnet 4.3

What are the browser(s) and version(s) where you see this issue?

msedge 103.0.1264.77

What are the browser driver(s) and version(s) where you see this issue?

msedgedriver 103.0.1264.77

Are you using Selenium Grid?

No

flysky2005 avatar Aug 04 '22 05:08 flysky2005

@flysky2005, 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!

github-actions[bot] avatar Aug 04 '22 05:08 github-actions[bot]

Can you please share a more complete code snippet? I was not able to reproduce this.

diemol avatar Aug 04 '22 08:08 diemol

Hi, @flysky2005. Please follow the issue template, we need more information to reproduce the issue.

Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.

Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.

Reply to this issue when all information is provided, thank you.

github-actions[bot] avatar Aug 04 '22 08:08 github-actions[bot]

        private void button1_Click(object sender, EventArgs e)
        {
            EdgeOptions options = new EdgeOptions();
            options.AddArguments("start-maximized");
            options.AddExcludedArgument("enable-automation");
           
            var debugHost = "127.0.0.1";
            var debugPort = 45411;
            options.AddArgument($"--remote-debugging-host={debugHost}");
            options.AddArgument($"--remote-debugging-port={debugPort}");
            options.DebuggerAddress = $"{debugHost}:{debugPort}";
            var service = EdgeDriverService.CreateDefaultService();
            //----- Create ChromeDriver -----
            
            driver = new EdgeDriver(service, options, TimeSpan.FromSeconds(40));

            driver.Navigate().GoToUrl("www.bing.com");
        }

flysky2005 avatar Aug 05 '22 02:08 flysky2005

I was able to see the issue. We are going to work on it. As a workaround for now, please comment out the line below and it should work.

EdgeOptions options = new EdgeOptions();
options.AddArguments("start-maximized");
options.AddExcludedArgument("enable-automation");

var debugHost = "127.0.0.1";
var debugPort = 45411;
options.AddArgument($"remote-debugging-host={debugHost}");
options.AddArgument($"remote-debugging-port={debugPort}");
//options.DebuggerAddress = $"{debugHost}:{debugPort}"; <== Comment out this line

EdgeDriver driver = new EdgeDriver(options);
driver.Navigate().GoToUrl("https://www.bing.com/");
driver.Quit();

diemol avatar Aug 08 '22 12:08 diemol

I was able to reproduce the issue and triage it. There is a bug in how Selenium C# is sending "debuggerAddress" to the browser. It should be part of the "args" but sending it as a capability.

{[]: newSession {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["start-maximized","--remote-debugging-host=127.0.0.1","--remote-debugging-port=45411"],"debuggerAddress":"127.0.0.1:45411","excludeSwitches":["enable-automation"]}}]}}}

I have some changes made on my local to fix it but I am still iterating over the best way to fix this. Meanwhile, please use the code snippet below as a workaround:

 EdgeOptions options = new EdgeOptions();

            options.AddArguments("start-maximized");
            options.AddExcludedArgument("enable-automation");

            var debugHost = "127.0.0.1";
            var debugPort = 45411;
            options.AddArgument($"remote-debugging-host={debugHost}");
            options.AddArgument($"remote-debugging-port={debugPort}");
            options.AddArgument($"debuggerAddress={debugHost}:{debugPort}");
            //  options.DebuggerAddress = $"{debugHost}:{debugPort}";

            EdgeDriver driver = new EdgeDriver(options);

            driver.Navigate().GoToUrl("https://www.bing.com/");
            driver.Quit();

pujagani avatar Aug 10 '22 12:08 pujagani

According to the Chromedriver docs it is its own capability, and even the driver code itself appears to support it — https://github.com/bayandin/chromedriver/blob/main/capabilities.cc#L598-L599

If it is not working, then I think this is a chromedriver bug, and not a problem with Selenium code.

titusfortner avatar Aug 12 '22 17:08 titusfortner

+1 with Titus's comment. Selenium seems to have done the right thing. https://chromedriver.chromium.org/capabilities#h.p_ID_102 also mentions it needs to be top-level capability. I could see this error as far as Chrome version 85.

pujagani avatar Aug 16 '22 06:08 pujagani

thank you

flysky2005 avatar Aug 16 '22 06:08 flysky2005

Hi, @flysky2005. This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team. Feel free to comment the issues that you raise back in this issue. Thank you.

github-actions[bot] avatar Aug 16 '22 07:08 github-actions[bot]

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[bot] avatar Sep 16 '22 00:09 github-actions[bot]