1. selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
2. Can not connect to the Service chrome-driver
解决方法:
1. 确保你的webdriver(如safaridriver、phantomjs等)已经下载并解压存放在你的环境变量目录下
我的存放目录:/usr/bin/chromedriver
检查方式:terminal中输入which chromedriver
2.如果仍然不行,请尝试 ping localhost
在缺失127.0.0.1 localhost的情况下,会出现Cannot connect to the service... 错误,修改之后selenium使用正常
测试代码:
from selenium import webdriver
driver = webdriver.Chrome() # 这里调用chrome浏览器
driver.get('https://www.baidu.com')
print(driver.title)
driver.quit()