0
votes

I have a python webdriver script which successfully runs the test on the remote server using firefox, however it throws an error when using chrome and internet explorer.

I have added the directory with both drivers to the server's path. I have also tried starting the server using: java -jar .\selenium-server-standalone-2.45.0.jar -Dwebdriver.ie.driver=.\IEDriverServer.exe -role hub

I consistently get the same error in powershell:

"... - Exception: The path to the driver executable must be set by the webdriver.chrome.driver system property;..."

Working Script:

def setUp(self):
    self.wd = webdriver.Remote(
        desired_capabilities=DesiredCapabilities.FIREFOX)

Throws Error:

def setUp(self):
    self.wd = webdriver.Remote(
        desired_capabilities=DesiredCapabilities.CHROME)

What is the culprit of this problem?

3

3 Answers

0
votes

You have the Selenium driver for Firefox installed and configured, but not for Chrome. Installing and configuring boils down to this (source):

Setup

ChromeDriver is a separate executable that WebDriver uses to control Chrome. It is maintained by the Chromium team with help from WebDriver contributors. If you are unfamiliar with WebDriver, you should check out their own Getting Started page.

Follow these steps to setup your tests for running with ChromeDriver:

  • Ensure Chromium/Google Chrome is installed in a recognized location ChromeDriver expects you to have Chrome installed in the default location for your platform. You can also force ChromeDriver to use a custom location by setting a special capability.
  • Download the ChromeDriver binary for your platform under the downloads section of this site
  • Help WebDriver find the downloaded ChromeDriver executable Any of these steps should do the trick:
    • include the ChromeDriver location in your PATH environment variable
    • (Java only) specify its location via the webdriver.chrome.driver system property (see sample below)
    • (Python only) include the path to ChromeDriver when instantiating webdriver.Chrome (see sample below)

So, basically, you need to either set the path to your Chrome drive in the PATH, or instantiate the drive like this:

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

Download the Chromedriver

from selenium import webdriver

driver = webdriver.Chrome('C:\\Users\\xxx\\Downloads\\chromedriver_win32\\chromedriver.exe')
driver.get("http://www.seleniumhq.org/")
0
votes

The code is for JAVA , set the path similarly in python

If the PATH is not set in your environment variable , then set it programmatically as below:

System.setProperty("webdriver.chrome.driver", "Path_to_your_chromedriver.exe");
driver = new ChromeDriver();