如何隐藏微软边缘SeleniumTools的命令提示符?

问题描述 投票:0回答:1

Hi I'm using selenium to open edge(Chromium) then navigate to a URL.written in c# windowsform application.

以下是代码

IWebDriver edgeDriver;

                    var options = new EdgeOptions();
                    options.UseChromium = true;

                     edgeDriver = new EdgeDriver(options);
                    edgeDriver.Navigate().GoToUrl(@Config.SpcUrl);

运转正常

我试着用以下方法隐藏命令提示符

IWebDriver edgeDriver;
     var chromeDriverService = EdgeDriverService.CreateDefaultService();
                        chromeDriverService.HideCommandPromptWindow = true;
                        var options = new EdgeOptions();
                        options.UseChromium = true;

                         edgeDriver = new EdgeDriver(chromeDriverService ,options);
                        edgeDriver.Navigate().GoToUrl(@Config.SpcUrl);

但它给我的错误是

An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in Microsoft.Edge.SeleniumTools.dll

Additional information: options.UseChromium must be set to false when using an Edge Legacy driver service.

我做错了什么,或者我错过了什么?

c# .net winforms selenium microsoft-edge
1个回答
0
投票

解决我使用 CreateChromiumService 不在 EdgeOptions

所以最后的代码是这样的

 var chromeDriverService = EdgeDriverService.CreateChromiumService();
                    chromeDriverService.HideCommandPromptWindow = true;
                    var options = new EdgeOptions();
                    options.UseChromium = true;

                    edgeDriver = new EdgeDriver(chromeDriverService, options);
                    edgeDriver.Navigate().GoToUrl(@Config.SpcUrl);
© www.soinside.com 2019 - 2024. All rights reserved.