2

I use selenium in a my django app and I can not setting Chrome browser. the environment is debian and I use Xvfb. This is my code:

import os
from selenium import webdriver

os.environ["DISPLAY"]=":56017"

def start_chrome(url):

    chromedriver = "/dir/app/chromedriver" #dir where I have the chromedriver
    os.environ["webdriver.chrome.driver"] = chromedriver
    driver = webdriver.Chrome("path/browser/chrome") #path where is chrome.exe
    driver.get(url)
    driver.quit()

I get: "Message: 'Can not connect to the ChromeDriver'". Where is the error? Thanks for your help

EDIT: I change the code:

def start_chrome(url):
    chromedriver = "/dir/app" #dir where I have the chromedriver
    os.environ["webdriver.chrome.driver"] = chromedriver
    driver = webdriver.Chrome(chromedriver)
    driver.get(url) 
    driver.quit()

I get: Message: 'ChromeDriver executable needs to be available in the path. Please download from http://code.google.com/p/selenium/downloads/list and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'

Can anyone help me? I do not know what to do. thanks

RoverDar
  • 441
  • 2
  • 12
  • 32

2 Answers2

1

Check chromedriver binary version matches your system. i.e. 32bit or 64bit. You need to have the right version otherwise you will receive this error.

Nathan Keller
  • 1,524
  • 3
  • 13
  • 17
0

You need to make sure the standalone ChromeDriver binary (which is different than the Chrome browser binary) is either in your path or available in the webdriver.chrome.driver environment variable.

driver = webdriver.Chrome(chromedriver)

Also take a look at that question

Community
  • 1
  • 1
Sergey Lyapustin
  • 1,917
  • 17
  • 27
  • The file is in the dir and available in the webdriver.chrome.driver environment variable. I am in Debian. It 'possible that the file is not executable or that I have not set any variable? I did this: I copied the files in the / home / dir / cromedriver, I installed chrome browser and I rest chromedriver executable file. I forgot something? – RoverDar Jan 31 '13 at 12:45