请问在这种情况下如何让硒发挥作用?我已经多次看到这个问题,但答案很少或没有,我希望今天运气站在我这边。
让我首先详细介绍我的环境。
- 我在跑步macOS 塞拉利昂.
-
我在用virtualenv/virtualenvwrapper with python3运行
下列的。
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()
在我遵循类似问题的示例后添加了以下几行here https://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium?answertab=votes#tab-top
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并添加路径如下:
/用户/我/下载/chromedriver
我尝试过不将参数传递给驱动程序,但仍然收到此错误。
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
对季节的补充和提前致谢。
你试过这个吗?
webdriver.Chrome("/usr/local/bin/chromedriver")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)