【发布时间】:2018-06-06 18:52:17
【问题描述】:
我在本地有以下环境 铬 67 Python 3.5.0 硒 3.12.0
我已经下载了 chromedriver 2.39 版
我有 .py 文件如下
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path="hromedriver.exe")
driver.get('http://www.google.com')
time.sleep(5)
search_box = driver.find_element_by_name('q')
search_box.send_keys('Python')
search_box.submit()
time.sleep(5)
driver.quit()
我收到以下错误。
C:\Python354\python.exe D:/formf.py
Traceback (most recent call last):
File "D:/PCPNDT/form.py", line 4, in <module>
driver = webdriver.Chrome(executable_path="chromedriver.exe") # Optional argument, if not specified will search path.
File "C:\Python354\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
self.service.start()
File "C:\Python354\lib\site-packages\selenium\webdriver\common\service.py", line 104, 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.exe
我也尝试过使用 geckodriver.exe 等其他 webdriver 仍然出现同样的错误。
请帮我解决这个错误。
谢谢!
【问题讨论】:
-
如果你在linux下需要把下载的chrome驱动放到usr/local/bin下再试一次?
标签: python selenium selenium-webdriver webdriver selenium-chromedriver