Site icon Tutorial

Vskills Configuring Selenium WebDriver Using C# & Python

Configuring Selenium Web Driver Using C#, Python & Ruby

Configuring Selenium WebDriver

Let’s learn how to configure Selenium WebDriver using various programming languages.

Configuring Selenium WebDriver C#

As of Selenium 2.2.0, the C# bindings are distributed as a set of signed along with other dependencies. Prior to 2.2.0, all Selenium dll’s were unsigned. To include Selenium in the project, simply download the latest selenium-dotnet zip file from http://selenium-release.storage.googleapis.com/index.html. If you are using Windows Vista or above, you should unblock the zip file before unzipping it: Right-click on the zip file, click “Properties”, click “Unblock” and click “OK”.

Unzip the contents of the zip file, and add a reference to each of the unzipped dlls to project in Visual Studio (or IDE of choice).

Configuring Python

If you are using Python for test automation then you probably are already familiar with developing in Python. To add Selenium to the Python environment run the following command from a command-line.

Both of the methods described above install selenium as a system-wide package and will require administrative/root access to the machine. You may consider using virtual to create isolated Python environments. Python 3.4 has pyvenv which is almost same as virtual.

An example having the steps to open a new Firefox browser and load the page at the given URL

from selenium import webdriver

browser = webdriver.Firefox()

browser.get(‘http://seleniumhq.org/’)

Configuring Ruby

If you are using Ruby for test automation then you probably are already familiar with developing in Ruby. To add Selenium to Ruby environment run the following command from a command-line.

gem install selenium-webdriver

The Ruby bindings for Selenium/WebDriver are available as the selenium-webdriver gem. There are many other Selenium gems out there, but this is the only official, maintained gem. The bindings support Ruby 1.9.2 through 2.1.

The gem also includes the older selenium-client gem for use with Selenium RC. When reading the docs, keep in mind that these two namespaces refer to different APIs:

Go back to Tutorial                                                                                Go to Home Page

Exit mobile version