【发布时间】:2020-08-29 19:55:43
【问题描述】:
我已经尝试了各种解决方案来解决这个问题。 系统配置:
- MacOS Catalina
- Python 3.7.6 (Anaconda)
- 硒 3.141
-
Chrome v81、ChromeDriver v81。
错误:无法连接到服务 chromedriver。
我已经尝试过使用各种驱动程序和浏览器:Gecko/Firefox(全新安装)、Safaridriver/Safar - 都出现相同的错误。
chromedriver、geckodriver 在 PATH 以及 usr/local/bin 中。
要重现的代码:
from selenium import webdriver
chromedriver = '/usr/local/bin/chromedriver'
driver = webdriver.Chrome(chromedriver)
我也尝试了各种解决方案,executable_path=chromedriver 和 hosts file with localhost 127.0.0.1 entry。
chromedriver 本身运行完美,没有任何问题,它似乎无法连接到 Selenium。
如有可能,我们将不胜感激。
预期结果:Selenium connects to driver
实际结果:raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /usr/local/bin/chromedriver
已经尝试过的解决方案:
以及其他关于 SO 的解决方案。
【问题讨论】:
-
您尝试过这样做吗? github.com/SeleniumHQ/selenium/issues/…
-
我试过了,它专注于hosts文件中的localhost地址。它什么也没做,一切都已经是它应该的样子了。 @Naveen
-
你能尝试按照这个答案stackoverflow.com/a/39428368/7964299启动Chrome吗?
-
我试过了,没用。错误保持不变。 @Naveen
标签: python selenium selenium-webdriver selenium-chromedriver