<legend id='aIL9t'><style id='aIL9t'><dir id='aIL9t'><q id='aIL9t'></q></dir></style></legend>
    1. <tfoot id='aIL9t'></tfoot>

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

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

        • <bdo id='aIL9t'></bdo><ul id='aIL9t'></ul>

        Selenium ChromeDriver 无法识别新编译的 Headless Chromium (Python)

        时间:2023-07-05

          1. <small id='rbpcJ'></small><noframes id='rbpcJ'>

            <legend id='rbpcJ'><style id='rbpcJ'><dir id='rbpcJ'><q id='rbpcJ'></q></dir></style></legend>
              • <bdo id='rbpcJ'></bdo><ul id='rbpcJ'></ul>

                  <tbody id='rbpcJ'></tbody>
                <i id='rbpcJ'><tr id='rbpcJ'><dt id='rbpcJ'><q id='rbpcJ'><span id='rbpcJ'><b id='rbpcJ'><form id='rbpcJ'><ins id='rbpcJ'></ins><ul id='rbpcJ'></ul><sub id='rbpcJ'></sub></form><legend id='rbpcJ'></legend><bdo id='rbpcJ'><pre id='rbpcJ'><center id='rbpcJ'></center></pre></bdo></b><th id='rbpcJ'></th></span></q></dt></tr></i><div id='rbpcJ'><tfoot id='rbpcJ'></tfoot><dl id='rbpcJ'><fieldset id='rbpcJ'></fieldset></dl></div>
                  <tfoot id='rbpcJ'></tfoot>
                • 本文介绍了Selenium ChromeDriver 无法识别新编译的 Headless Chromium (Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将新的 (2016) headless 版本的 Chromium 与 Selenium/ChromeDriver 一起使用(过去,我将 Firefox 与 xfvb 一起使用,但这有望更好).

                  I am trying to use the new (2016) headless version of Chromium with Selenium/ChromeDriver (In the past, I used Firefox with xfvb but this promises to be much better).

                  我根据我找到的说明从源代码编译了一个无头版本的 Chromium(我没有找到任何预构建的二进制文件)here 然后我使用以下代码通过 Selenium 启动它:

                  I have compiled a headless version of Chromium from sources (I did not find any pre-built binaries) based on the instructions I found here and then I used the following code to launch it through Selenium:

                  from selenium import webdriver
                  from selenium.webdriver.chrome.options import Options
                  
                  l_option = Options()
                  l_option.add_argument('headless')
                  l_option.add_argument('disable-notifications')
                  l_option.binary_location = '/home/fi11222/Headless_Chromium/headless_shell'
                  l_driver = webdriver.Chrome(chrome_options=l_option)
                  

                  相同的代码适用于标准铬(如果我删除 binary.location 选项)

                  The same code works with the standard chromium (if I remove the binary.location option)

                  但是,我收到以下错误:

                  As is, however, I get the following error:

                  selenium.common.exceptions.WebDriverException: Message: unknown error: unrecognized Chrome version: HeadlessChrome/59.0.3032.0
                    (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 4.4.0-53-generic x86_64)
                  

                  显然,无头 chromium 二进制文件是使用 ChromeDriver 无法识别的版本 ID 编译的.救命!!

                  Apparently, the headless chromium binary is compiled with a version ID that ChromeDriver does not recognize. Help !!

                  环境:

                  • 编译:Ubuntu 16.04 服务器
                  • Selenium 执行:Linux Mint 18.1

                  推荐答案

                  ChromeHeadless 被 chromedriver 识别,因为 此补丁(在您发布消息后创建),仅在 chromedriver 2.29(2017 年 4 月发布)之后可用.确保您在 PATH 中具有此 chromedriver 可执行文件,并且 Selenium 正在选择它,而不是您可能拥有的任何其他 chromedriver.

                  ChromeHeadless is recognized by chromedriver since this patch (created after you have post your message), which is only available since chromedriver 2.29 (released in April 2017). Make sure that you have this chromedriver executable available in PATH and that Selenium is picking it instead of any other chromedriver you might have available.

                  另外,请注意 - 根据 无头 Chrome 文档 - 你需要再传递两个标志:

                  Also, please note that - according to headless Chrome documentation - you need to pass two more flags:

                  l_option.add_argument('remote-debugging-port=9222')
                  l_option.add_argument('disable-gpu')
                  

                  至于无头 Chrome 的预构建二进制文件 - 该选项自 Chrome 57 起可用,因此当前通过官方 Google 存储库分发的所有版本都支持它(即稳定的 Chrome 58 和不稳定的 Chrome 59).它是 Chrome 59 的亮点,所以在功能稳定之前,请期待一些粗糙的边缘.

                  As for pre-built binaries of headless Chrome - that option is available since Chrome 57, so it is supported by all versions currently distributed through official Google repository (i.e. stable Chrome 58 and unstable Chrome 59). It is highlight of Chrome 59, so expect some rough edges until feature is stabilized.

                  这篇关于Selenium ChromeDriver 无法识别新编译的 Headless Chromium (Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:chrome自动化中的假地理位置 下一篇:如何防止在打开特定链接时从 Ubuntu chrome 弹出 xdg-open 对话?

                  相关文章

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

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

                  2. <legend id='xLZ0h'><style id='xLZ0h'><dir id='xLZ0h'><q id='xLZ0h'></q></dir></style></legend>
                    • <bdo id='xLZ0h'></bdo><ul id='xLZ0h'></ul>

                      <tfoot id='xLZ0h'></tfoot>