How to start ChromeDriver in headless mode

前端 未结 5 1700
天命终不由人
天命终不由人 2020-12-04 13:24

I want to try out headless chrome, but I am running into this issue, that I can\'t start the driver in headless mode. I was following google documentation. am I missing some

5条回答
  •  一生所求
    2020-12-04 13:57

    As alternative:

    • Add 2 libraries via NuGet like below picture.

    • Try below Code:

      String url = "http://www.google.com";
      var chromeOptions = new ChromeOptions();
      chromeOptions.AddArguments(new List() { "headless" });
      
      var chromeDriverService = ChromeDriverService.CreateDefaultService();
      ChromeDriver driver = new ChromeDriver(chromeDriverService, chromeOptions);
      driver.Navigate().GoToUrl(url);
      

提交回复
热议问题