【问题标题】:Is my Selenium Chrome Headless browser working as it should?我的 Selenium Chrome Headless 浏览器是否正常工作?
【发布时间】:2018-06-03 13:02:03
【问题描述】:

我正在尝试使用 Selenium 与无头参数建立与 Google 的连接,因为我不想弹出网络浏览器。 这就是我得到的 This is what it looks like

public static void Main(string[] args)
        {
            LoadPage();
        }

        private static void LoadPage()
        {
            string path = @"C:\Users\Dev\Documents\";
            ChromeOptions option = new ChromeOptions();

            IWebDriver _driver;
            option.AddArgument("--headless");
            _driver = new ChromeDriver(path, option);
            _driver.Navigate().GoToUrl("http://Google.com");
            Console.WriteLine("Done");
        }

如何确保我确实连接到 Google?

【问题讨论】:

  • 从页面中读取一些内容并输出?
  • @gilliduck 所以它确实建立了连接,关于只有本地连接的全部内容..
  • 不记得了,但我相信这很正常。如果这样做成功了,我会尽快将其添加为您接受的答案。

标签: c# .net google-chrome selenium chromium


【解决方案1】:

根据google,您必须禁用 GPU。然后你不会看到那个错误。这只是暂时的解决方法。

IWebDriver _driver;
option.AddArgument("--headless");
option.AddArgument("--disable-gpu");

(不知道禁用GPU有什么影响)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    • 1970-01-01
    • 2022-01-08
    • 2011-12-09
    • 1970-01-01
    • 1970-01-01
    • 2021-03-10
    相关资源
    最近更新 更多