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 但仍然收到此错误。
请帮我。
谢谢
最佳答案
通过参数 executable_path
您需要传递 ChromeDriver 的绝对路径而不是任何其他文件。所以你需要改变:
driver = webdriver.Chrome(executable_path="/home/cavema11/public_html/testing.py")
至:
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
更新
/etc/hosts
文件包含以下条目:127.0.0.1 localhost
executable_path
传递 ChromeDriver 二进制文件的正确绝对路径。 (chmod 777) 关于python-3.x - Linux服务器中的Python Selenium "Can not connect to the Service %s"% self.path,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50753093/