4

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

I have 127.0.0.1 localhost in my /etc/hosts but still getting this errors.

Please help me.

Thank you

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
user9912010
  • 107
  • 2
  • 8

1 Answers1

3

Through the argument executable_path you need to pass the absolute path of the ChromeDriver instead of any other file. So you need to change:

driver = webdriver.Chrome(executable_path="/home/cavema11/public_html/testing.py")

To:

driver = webdriver.Chrome(executable_path='/path/to/chromedriver')

Update

  • Ensure that you have downloaded the exact format of the ChromeDriver binary from the download location pertaining to your underlying OS among:

    • chromedriver_linux64.zip: For Linux OS
    • chromedriver_mac64.zip: For Mac OSX
    • chromedriver_win32.zip: For Windows OS
  • Ensure that /etc/hosts file contains the following entry:

    127.0.0.1 localhost 
    
  • Ensure that ChromeDriver binary have executable permission for the non-root user.

  • Ensure that you have passed the proper absolute path of ChromeDriver binary through the argument executable_path. (chmod 777)
  • Execute your Test as a non-root user.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks for reply. Getting another error after i change. Here is the error : OSError: [Errno 8] Exec format error: '/home/cavema11/public_html/chromedriver.exe' – user9912010 Jun 08 '18 at 04:31
  • You are on _Linux OS_ and need to remove the extension part as in `.exe` – undetected Selenium Jun 08 '18 at 04:33
  • @user9912010 Checkout my updated answer and let me know the status. – undetected Selenium Jun 08 '18 at 06:37
  • I'm getting this error now "Message: unknown error: cannot find Chrome binary" – user9912010 Jun 08 '18 at 07:20
  • You got _Linux OS_, 1) Which `chromedriver` binary did you download? 2) At which location did you extract it? 3) Did you put the same _absolute location_ of _chromedriver_ binary in your code? – undetected Selenium Jun 08 '18 at 07:25
  • 1) 2.39 2) in /public_html 3) driver = webdriver.Chrome(executable_path="/home/cavema11/public_html/chromedriver") – user9912010 Jun 08 '18 at 07:42
  • Within my _Windows OS_ all the variants are shown with `.zip` extension. But as you are on _Linux OS_ you should download `chromedriver_linux64.tar` or `chromedriver_linux64.tz`. Untar it and change the permissions through `chmod 777` first – undetected Selenium Jun 08 '18 at 07:47
  • Okay, i have untar and change permission to 777 for chromedriver – user9912010 Jun 08 '18 at 08:12
  • What is the status? – undetected Selenium Jun 08 '18 at 08:15
  • still getting the same error **selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary** **(Driver info: chromedriver=2.39.562737 (dba483cee6a5f15e2e2d73df16968ab10b38a2bf),platform=Linux 3.10.0-862.3.2.el7.x86_64 x86_64)** – user9912010 Jun 08 '18 at 08:18
  • 1
    Thanks for your help @DebanjanB – user9912010 Jun 08 '18 at 08:33
  • @user9912010 If you change the original question the answer will not match the updated question and won't be helpful to future readers. Instead raise a new question as per your new requirement. I am reverting back the question to the original version – undetected Selenium Jun 08 '18 at 09:28