在硒中使用chromedriver打开chrome时出现问题。即使我尝试将firefox与geckodriver一起使用时,问题仍然不断出现。
经过研究,我发现了很多关于stackoverflow的问题,例如:
...更多我忘了(实际上花了半天时间找到)...
并且在firefox github issue #230中,他们建议我在127.0.0.1 localhost
上添加/etc/hosts
,但是并不能解决问题。
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python36\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
from selenium import webdriver
browser = webdriver.Chrome(executable_path="/path/to/chromedriver") # Did not work !!!!!!!
上面的代码暂停了大约8分钟并产生了上面的输出
chromedriver.exe
和geckodriver.exe
都添加到PATH也是不可能的。/etc/hosts
重置为默认设置无效。