<i id='iMgvh'><tr id='iMgvh'><dt id='iMgvh'><q id='iMgvh'><span id='iMgvh'><b id='iMgvh'><form id='iMgvh'><ins id='iMgvh'></ins><ul id='iMgvh'></ul><sub id='iMgvh'></sub></form><legend id='iMgvh'></legend><bdo id='iMgvh'><pre id='iMgvh'><center id='iMgvh'></center></pre></bdo></b><th id='iMgvh'></th></span></q></dt></tr></i><div id='iMgvh'><tfoot id='iMgvh'></tfoot><dl id='iMgvh'><fieldset id='iMgvh'></fieldset></dl></div>

        <bdo id='iMgvh'></bdo><ul id='iMgvh'></ul>
    1. <legend id='iMgvh'><style id='iMgvh'><dir id='iMgvh'><q id='iMgvh'></q></dir></style></legend>

      1. <tfoot id='iMgvh'></tfoot>

        <small id='iMgvh'></small><noframes id='iMgvh'>

      2. 如何在无头模式下启动 ChromeDriver

        How to start ChromeDriver in headless mode(如何在无头模式下启动 ChromeDriver)
        • <legend id='PAP45'><style id='PAP45'><dir id='PAP45'><q id='PAP45'></q></dir></style></legend>
            <tbody id='PAP45'></tbody>
            <bdo id='PAP45'></bdo><ul id='PAP45'></ul>

                <i id='PAP45'><tr id='PAP45'><dt id='PAP45'><q id='PAP45'><span id='PAP45'><b id='PAP45'><form id='PAP45'><ins id='PAP45'></ins><ul id='PAP45'></ul><sub id='PAP45'></sub></form><legend id='PAP45'></legend><bdo id='PAP45'><pre id='PAP45'><center id='PAP45'></center></pre></bdo></b><th id='PAP45'></th></span></q></dt></tr></i><div id='PAP45'><tfoot id='PAP45'></tfoot><dl id='PAP45'><fieldset id='PAP45'></fieldset></dl></div>

                • <small id='PAP45'></small><noframes id='PAP45'>

                  <tfoot id='PAP45'></tfoot>
                • 本文介绍了如何在无头模式下启动 ChromeDriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想试试 headless chrome,但我遇到了这个问题,我无法在 headless 模式下启动驱动程序.我正在关注 google 文档.我错过了什么吗?代码执行卡在 var browser = new ChromeDriver();

                  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 something ? The code execution gets stuck in var browser = new ChromeDriver(); line

                  这是我的代码:

                  var chromeOptions = new ChromeOptions
                  {
                      BinaryLocation = @"C:Users2-as AukstasDocumentsVisual Studio 2017ProjectsChromeTestChromeTestinDebugchromedriver.exe",
                      DebuggerAddress = "localhost:9222"
                  };
                  
                  chromeOptions.AddArguments(new List<string>() {"headless", "disable-gpu" });
                  
                  var browser = new ChromeDriver(chromeOptions);
                  
                  
                  browser.Navigate().GoToUrl("https://stackoverflow.com/");
                  Console.WriteLine(browser.FindElement(By.CssSelector("#h-top-questions")).Text);
                  

                  推荐答案

                  更新
                  Chrome 60 版已经发布,所以您只需通过 Nuget 下载 Chromdriver 和 Selenium 并使用这个简单的代码,一切都会像魅力一样运行.太棒了.

                  UPDATE
                  Chrome version 60 is out so all you need to do is to download Chromdriver and Selenium via Nuget and use this simple code and everything works like a charm. Amazing.

                  using OpenQA.Selenium;
                  using OpenQA.Selenium.Chrome;
                  
                  ...
                  
                  
                  
                  var chromeOptions = new ChromeOptions();
                  chromeOptions.AddArguments("headless");
                  
                  using (var browser = new ChromeDriver(chromeOptions))
                  {
                    // add your code here
                  }
                  

                  日期

                  在 Chrome 60 正式版发布之前,有一个解决方案.您可以下载 Chrome Canary 并使用 headless.安装后将 BinaryLocation 设置为指向 chrome canary 还注释掉 DebuggerAddress 行(它强制 chrome 超时):

                  There is a solution until the official release of Chrome 60 will be released. You can download Chrome Canary and use headless with it. After installation set BinaryLocation to point to chrome canary also comment out the DebuggerAddress line(it forces chrome to timeout):

                  var chromeOptions = new ChromeOptions
                  {
                      BinaryLocation = @"C:Users2-as AukstasAppDataLocalGoogleChrome SxSApplicationchrome.exe",
                      //DebuggerAddress = "127.0.0.1:9222"
                  };
                  
                  chromeOptions.AddArguments(new List<string>() { "no-sandbox", "headless", "disable-gpu" });
                  
                  var _driver = new ChromeDriver(chromeOptions);
                  

                  这篇关于如何在无头模式下启动 ChromeDriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)

                    <small id='iy314'></small><noframes id='iy314'>

                      <bdo id='iy314'></bdo><ul id='iy314'></ul>
                    • <tfoot id='iy314'></tfoot>

                        <tbody id='iy314'></tbody>

                        1. <i id='iy314'><tr id='iy314'><dt id='iy314'><q id='iy314'><span id='iy314'><b id='iy314'><form id='iy314'><ins id='iy314'></ins><ul id='iy314'></ul><sub id='iy314'></sub></form><legend id='iy314'></legend><bdo id='iy314'><pre id='iy314'><center id='iy314'></center></pre></bdo></b><th id='iy314'></th></span></q></dt></tr></i><div id='iy314'><tfoot id='iy314'></tfoot><dl id='iy314'><fieldset id='iy314'></fieldset></dl></div>
                        2. <legend id='iy314'><style id='iy314'><dir id='iy314'><q id='iy314'></q></dir></style></legend>