Traceback (most recent call last):
File "testing.py", line 20, in <module>
driver = webdriver.Chrome(executable_path="/home/cavema11/public_html/testing.py")
File "/opt/python-3.6.4/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/opt/python-3.6.4/lib/python3.6/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 /home/cavema11/public_html/testing.py
我的/ etc / hosts中有127.0.0.1 localhost,但仍然出现此错误。
请帮帮我。
谢谢
答案 0 :(得分:3)
通过参数executable_path
,您需要传递 ChromeDriver 的绝对路径,而不是任何其他文件。所以你需要改变:
driver = webdriver.Chrome(executable_path="/home/cavema11/public_html/testing.py")
要:
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
确保您已从以下基础操作系统的download location下载 ChromeDriver 二进制文件的确切格式:
确保/etc/hosts
文件包含以下条目:
127.0.0.1 localhost
确保 ChromeDriver 二进制文件具有非root 用户的可执行权限。
executable_path
传递了 ChromeDriver 二进制文件的正确绝对路径。 (chmod 777)