Selenium和Python3 ChromeDriver引发消息:无法连接到服务chromedriver [英] Selenium and Python3 ChromeDriver raises Message: Can not connect to the Service chromedriver
问题描述
请在这个场景中如何使硒工作?我看过这个问题的时间很少或没有答案,我希望今天运气在我身边.
Please how do get selenium working in this scenerio? I have seen this questions times with fewer or no answers and i hope luck is on my side today.
让我从详细介绍我的环境开始.
Let me start by detailing my environment.
- 我正在运行 MacOS Seirra .
-
我正在将 virtualenv/virtualenvwrapper 与 python3 结合使用,以运行 正在关注.
- I am running MacOS Seirra.
I am using virtualenv/virtualenvwrapper with python3 to run the following.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
chromedriver = "/usr/local/bin/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome()
driver.get("http://www.python.org")
print(driver.title)
driver.quit()
在我遵循类似问题这里
chromedriver = "/usr/local/bin/chromedriver" # i used brew to install chrome to get this path from the command 'which chromedriver'
os.environ["webdriver.chrome.driver"] = chromedriver
或者我直接从github下载chromedriver并添加了如下路径:
Alternatively i downloaded chromedriver directly from github and added the path as follows:
/用户/我/下载/chromedriver
/Users/Me/Downloads/chromedriver
我有没有将争论传递给驾驶员的三位一体,但我仍然遇到此错误.
I have triend not passing arguements to the driver but i still get this error.
Traceback (most recent call last):
File "aicpa.py", line 8, in <module>
driver = webdriver.Chrome()
File "/Users/Me/.virtualenvs/aicpa/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
self.service.start()
File "/Users/Me/.virtualenvs/aicpa/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 102, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver
季节的补充,在此先感谢.
Complements of the season and thanks in advance.
推荐答案
您尝试过吗?
webdriver.Chrome("/usr/local/bin/chromedriver")
这篇关于Selenium和Python3 ChromeDriver引发消息:无法连接到服务chromedriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!