答案 0 :(得分:2)
var chromeOptions = new ChromeOptions();
options.AddAdditionalCapability("excludeSwitches", ['enable-automation'])
options.AddArgument('--disable-blink-features=AutomationControlled')
options.AddArgument (
"user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36")
options.AddArgument("--remote-debugging-port=9222")
var driver = new ChromeDriver(chromeOptions);
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("window.open('https://www.paribu.com/')");
ReadOnlyCollection<string> windowHandles = driver.WindowHandles;
driver.SwitchTo().Window(windowHandles[0])
driver.close()
driver.SwitchTo().Window(windowHandles [1])
您可以禁用自动化标志并使用 win.open 打开网站。否则重定向将被阻止,网站会检测到自动化脚本