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

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

        <bdo id='ha4oF'></bdo><ul id='ha4oF'></ul>

      1. <tfoot id='ha4oF'></tfoot>
      2. selenium.common.exceptions.WebDriverException:消息:无法通过 Seleni

        selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service error using ChromeDriver Chrome through Selenium Python(selenium.common.exceptions.WebDriverException:消息:无法通过 Selenium Python 使用 ChromeDriver Chr

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

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

              <legend id='nHocA'><style id='nHocA'><dir id='nHocA'><q id='nHocA'></q></dir></style></legend>
            2. <tfoot id='nHocA'></tfoot>

                1. 本文介绍了selenium.common.exceptions.WebDriverException:消息:无法通过 Selenium Python 使用 ChromeDriver Chrome 连接到服务错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我在一台计算机上使用 selenium 制作了一个程序并且可以正常工作,现在在另一台计算机上使用它时出现此错误:

                  So I have made a program on one computer using selenium and that worked, Now using it in another computer I get this error:

                  selenium.common.exceptions.WebDriverException:消息:无法连接到服务 chromedriver

                  selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver

                  现在同样的问题被提及:

                  Now this same issue was mention in:

                  Selenium python:不能连接到服务 %s"% self.path

                  Selenium python:无法连接到服务 %s"% self.path

                  Selenium 和 Python3 ChromeDriver 引发消息:无法连接到服务 chromedriver

                  但是提到的解决方案不起作用.

                  however the solutions mentioned didnt work.

                  我正在使用 chrome 版本 79 并安装了 chromedriver 79,我测试了在命令行中编写 chromedriver,这意味着路径配置正确,我确保 127.0.0.1 localhost 也在 etc/hosts 中

                  I am using chrome version 79 and have installed chromedriver 79, I tested writing chromedriver in command line and that works which means path is configured right, I have made sure 127.0.0.1 localhost is also in etc/hosts

                  下面是在我的电脑上运行的代码(所以我怀疑它是代码的问题):

                  Below is my code which works on my computer (so i doubt its an issue with the code):

                  chrome_options = Options()   
                  chrome_options.add_argument("--headless")  
                  with webdriver.Chrome(chrome_options=chrome_options) as driver:
                      driver.set_window_size(800, 460) # takes two arguments, width and height of the browser and it has to be called before using get()
                      driver.execute_script("document.body.style.zoom='150%'")
                      driver.get("file:\"+url) # takes one argument, which is the url of the website you want to open
                      driver.find_element_by_tag_name('body').screenshot(output)  # avoids scrollbar
                  

                  上一个问题我也试过这个修改:

                  In the last question I also tried this modification:

                  chrome_options = Options()   
                  chrome_options.add_argument("--headless")  
                  with webdriver.Chrome("C:\chromedriver.exe",chrome_options=chrome_options) as driver:
                      driver.set_window_size(800, 460) # takes two arguments, width and height of the browser and it has to be called before using get()
                      driver.execute_script("document.body.style.zoom='150%'")
                      driver.get("file:\"+url) # takes one argument, which is the url of the website you want to open
                      driver.find_element_by_tag_name('body').screenshot(output)  # avoids scrollbar
                  

                  这反而会给我这个几乎相同的错误消息:

                  which would instead give me this almost identical error message:

                  selenium.common.exceptions.WebDriverException:消息:无法连接到服务 C:chromedriver.exe

                  selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service C:chromedriver.exe

                  我不确定问题出在哪里.

                  I am unsure where the issue could lie.

                  顺便说一句,我正在使用 Windows.

                  I am using windows by the way.

                  我尝试过但没有成功的方法:

                  1- 以管理员和正常方式运行所有内容

                  1- running everything as both admin and normal

                  2-重新安装chrome

                  2- re-installing chrome

                  3- 使用 beta-chroma 80 和 webdriver 80

                  3- using the beta-chroma 80 and webdriver 80

                  4- 使用普通的 chrome 79 和 webdriver 79

                  4- using normal chrome 79 and webdriver 79

                  5- 将脚本和驱动程序放在同一目录中(使用正确的路径)

                  5- Having both the script and the driver in the same directory (while using a correct path)

                  6- 拥有外部路径并根据需要进行设置

                  6- Having an external path and have it setup as needed

                  7- 在 PATH 文件夹中使用它.

                  7- Using it in the PATH folder.

                  8- 向 etc/hosts 添加127.0.0.1 localhost"

                  8- Adding "127.0.0.1 localhost" to etc/hosts

                  9- 运行服务测试

                  我已确保在每次测试中一切都在正确的位置,我在每次新测试之前都进行了重新启动,他们总是给我同样的错误,如果我的路径也不正确,也会发生这种情况,但是一旦我运行了服务的代码,它给了我一个不同的错误,因为我在 C:/中有我的 webdriver 需要管理员权限,但是使用正确的权限再次重新运行测试会返回相同的错误

                  I have ensured in every test that everything was in it's correct placement, I have ran a reboot before every new test, and they always give me the same error, which also happens to occur if I had an incorrect path as well, but once I ran the code for a service and it gave me a different error as I had my webdriver in C:/ which required admin privilages, however re-running the test again with the correct privilages gave back the same error

                  更新此问题并非 Chrome 驱动程序独有.即使遵循 Firefox 或边缘驱动程序的设置说明最终也会遇到相同的问题.这让我怀疑连接正面临一些问题.我已尝试运行 Mozilla 为设置提供的测试代码,但没有成功.

                  Update the issue isn't exclusive to the chrome driver. Even following setup instructions for either the Firefox or edge drivers end up on the same issues. It makes me suspect that the connection is facing some issue. I have tried running the test codes provided by Mozilla for the setup and it didn't work.

                  不确定这是否有很大帮助或根本没有帮助.

                  Unsure if that does help much or at all.

                  推荐答案

                  这个错误信息...

                  selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver
                  

                  ...暗示 ChromeDriver 无法启动/生成新的浏览上下文,即 Chrome 浏览器 会话.

                  ...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.

                  你需要注意几件事:

                  • 确保您已从 ChromeDriver 二进制文件的确切格式79.0.3945.36/" rel="nofollow noreferrer">下载位置 与您的底层操作系统有关:

                  • Ensure that you have downloaded the exact format of the ChromeDriver binary from the download location pertaining to your underlying OS among:

                  • chromedriver_linux64.zip:适用于 Linux 操作系统
                  • chromedriver_mac64.zip:适用于 Mac OSX
                  • chromedriver_win32.zip:适用于 Windows 操作系统
                  • chromedriver_linux64.zip: For Linux OS
                  • chromedriver_mac64.zip: For Mac OSX
                  • chromedriver_win32.zip: For Windows OS

                  确保 /etc/hosts 文件包含以下条目:

                  Ensure that /etc/hosts file contains the following entry:

                  127.0.0.1 localhost 
                  

                2. 确保 ChromeDriver 二进制文件对 非 root 用户具有可执行权限.

                3. Ensure that ChromeDriver binary have executable permission for the non-root user.

                  确保您已通过参数 executable_path 传递了正确的 ChromeDriver 二进制文件的绝对路径,如下所示:

                  Ensure that you have passed the proper absolute path of ChromeDriver binary through the argument executable_path as follows:

                  with webdriver.Chrome(executable_path=r'C:path	ochromedriver.exe', chrome_options=chrome_options) as driver:
                  

                4. 所以你的有效代码块将是:

                5. So your effective code block will be:

                  options = Options()   
                  options.add_argument("--headless")
                  options.add_argument('--no-sandbox') # Bypass OS security model
                  options.add_argument('--disable-gpu')  # applicable to windows os only
                  options.add_argument("--disable-dev-shm-usage")  # overcome limited resource problems
                  options.add_experimental_option("excludeSwitches", ["enable-automation"])
                  options.add_experimental_option('useAutomationExtension', False)
                  with webdriver.Chrome(executable_path=r'C:path	ochromedriver.exe', options=options) as driver:
                      driver.set_window_size(800, 460) # takes two arguments, width and height of the browser and it has to be called before 
                      driver.execute_script("document.body.style.zoom='150%'")
                      driver.get("file:\"+url) # takes one argument, which is the url of the website you want to open
                      driver.find_element_by_tag_name('body').screenshot(output)  # avoids scrollbar
                  

                6. 最后,为避免您使用的二进制文件版本之间出现不兼容,请确保:

                  Finally, to avoid incompatibility between the version of the binaries you are using ensure that:

                  • Selenium 已升级到当前级别版本 3.141.59.
                  • ChromeDriver 已更新为当前 ChromeDriver v79.0.3945.36 级别.
                  • Chrome 已更新至当前 Chrome 版本 79.0 级别.(根据 ChromeDriver v79.0 发行说明)
                  • 清理你的项目工作区通过你的IDE重建你的项目只需要依赖.
                  • 如果您的基本 Web 客户端 版本太旧,请卸载它并安装最新的 GA 和发布版本的 Web 客户端.
                  • 进行一次系统重启.
                  • 非 root 用户身份执行您的 @Test.
                  • Selenium is upgraded to current levels Version 3.141.59.
                  • ChromeDriver is updated to current ChromeDriver v79.0.3945.36 level.
                  • Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.0 release notes)
                  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
                  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
                  • Take a System Reboot.
                  • Execute your @Test as non-root user.

                  您可以在以下位置找到一些参考讨论:

                  You can find a couple of reference discussions in:

                  • Python Selenium 无法连接到服务 %s" % self.path in linux server
                  • selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver.exe while opening chrome browser
                  • 如何配置 ChromeDriver 以通过 Selenium 以 Headless 模式启动 Chrome 浏览器?

                  这篇关于selenium.common.exceptions.WebDriverException:消息:无法通过 Selenium Python 使用 ChromeDriver Chrome 连接到服务错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                  Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                  How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                  Centering an object in Kivy(在 Kivy 中将对象居中)
                  How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                  Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)
                7. <i id='sy1XA'><tr id='sy1XA'><dt id='sy1XA'><q id='sy1XA'><span id='sy1XA'><b id='sy1XA'><form id='sy1XA'><ins id='sy1XA'></ins><ul id='sy1XA'></ul><sub id='sy1XA'></sub></form><legend id='sy1XA'></legend><bdo id='sy1XA'><pre id='sy1XA'><center id='sy1XA'></center></pre></bdo></b><th id='sy1XA'></th></span></q></dt></tr></i><div id='sy1XA'><tfoot id='sy1XA'></tfoot><dl id='sy1XA'><fieldset id='sy1XA'></fieldset></dl></div>

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

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

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