为什么在 C# 中使用 excludeSwitches

Python 代码有效:


import time

from selenium import  webdriver

from selenium.webdriver.common.action_chains import ActionChains

options = webdriver.ChromeOptions()

options.add_experimental_option('excludeSwitches', ['enable-automation'])

但是 C# 代码不起作用:


ChromeOptions chromeOptions = new ChromeOptions();

chromeOptions.AddAdditionalCapability("excludeSwitches", "disable-popup-blocking");


撒科打诨
浏览 135回答 2
2回答

潇湘沐

&nbsp; &nbsp; List<string> ls = new List<string>();&nbsp; &nbsp; &nbsp; &nbsp; ls.Add("enable-automation");&nbsp; &nbsp; &nbsp; &nbsp; ChromeOptions options = new ChromeOptions();&nbsp; &nbsp; &nbsp; &nbsp; options.AddExcludedArguments(ls);&nbsp; &nbsp; &nbsp; &nbsp; using (IWebDriver driver = new ChromeDriver("C:\\Program\\chromedriver", options))&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.ReadKey();&nbsp; &nbsp; &nbsp; &nbsp; }

慕妹3146593

我使用“excludeSwitches”来消除输出控制台上显示的错误。 在 Windows 操作系统上使用 ChromeDriver Selenium 时,连接到系统的设备无法运行错误这是我的代码:var options = new ChromeOptions();List<string> ls = new List<string>();ls.Add("enable-automation");ls.Add("excludeSwitches");ls.Add("enable-logging");ls.Add("disable-popup-blocking");options.AddExcludedArguments(ls); //set option element in list to optionsIWebDriver driver = new ChromeDriver(options);&nbsp; //open webdriver with your options
打开App,查看更多内容
随时随地看视频慕课网APP