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).
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.
- pip install selenium
- Pip requires pip to be installed, pip also has a dependency on setuptools.
- Alternately, you can download the source distribution from PyPI (e.g. selenium-2.45.tar.gz), unarchive it, and run:
- python setup.py install
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()
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.
- API docs
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:
- Selenium::WebDriver – the WebDriver API
- Selenium::Client – Selenium RC API (previously released as the selenium-client gem)