硒铬驱动程序无头打开网站C#

时间:2018-08-07 07:56:58

标签: c# selenium

这是我的代码,带有打开的web.whatsapp.com网址,并添加了参数“无头”,因此无法打开页面,但可以选择要打开的浏览器。 那么如何避免浏览器选择并获取页面。 但没有“无头”功能,则可以轻松打开网页并且不要求选择任何选项

ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;

var options = new ChromeOptions();
options.AddArgument("headless");
Driver = new ChromeDriver(service, options);
Driver.Navigate().GoToUrl("https://web.whatsapp.com/");

img

1 个答案:

答案 0 :(得分:0)

对我有用的是在参数之前加一个双破折号。

chromeOptions.AddArgument("--headless");