「Selenium」- Can not connect to the Service /path/to/chromedriver

  CREATED BY JENKINSBOT

问题描述

# python3.7 /tmp/demo.py
Traceback (most recent call last):
  File "/tmp/demo.py", line 4, in <module>
    driver = webdriver.Chrome('/srv/sharing/packages/chromedriver_linux64/chromedriver')  # Optional argument, if not specified will search path.
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/usr/local/lib/python3.7/dist-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 /srv/sharing/packages/chromedriver_linux64/chromedriver

问题原因

Selenium python: Can not connect to the Service %s” % self.path
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver

解决办法

添加 127.0.1.1 localhost 到 /etc/hosts 文件。

参考文献

Selenium python: Can not connect to the Service %s” % self.path
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service geckodriver