Wednesday, February 15, 2012

Running Selenium Server

Before running any tests we must start the selenium server.
Navigate to the directory where Selenium RC’s server is located and run the server from a command-line.
           java -jar selenium-server-standalone-<version-number>.jar
In simple create a batch or shell executable file (.bat on Windows and .sh on Linux) containing the command above. Then make a shortcut to that executable on your desktop and simply double-click the icon to start the server when ever required.
Note:
      For the server to run you’ll need Java installed and the PATH environment variable correctly configured to run it from the console. You can check that you have Java correctly installed by running the following on a console.
          java -version
If you get a version number (which needs to be 1.5 or later), you’re ready to start using Selenium RC.

Getting started with Selenium RC (selenium 1)

Mainly there are two components of selenium rc i.e
  • Selenium Server
  • Client libraries
The Selenium server receives the Selenese commands from your test program using simple HTTP GET/POST requests. This means you can use any programming language that can send HTTP requests to automate Selenium tests on the browser.
A Selenium client library provides a programming interface (API), i.e., a set of functions, which run Selenium commands from your own program. Within each interface, there is a programming function that supports each Selenese command.

Installation:
      Selenium RC supports various programming languages like java, csharp(C#), python, ruby, php, perl etc. In my explanation I am using java.

Installing Selenium Server:
      The Selenium RC server doesn’t require any special installation which is simply a Java jar file (selenium-server-standalone-.jar). Just download the zip file from SeleniumHQ  downloads page and extract the server in the desired directory.

Using the Java Client Driver:
      Download Selenium java client driver zip from SeleniumHQ  downloads page and extract selenium-java-
.jar file.

Steps after having both client and server jars

  • Open your desired Java IDE (Eclipse, NetBeans, IntelliJ, Netweaver, etc. in my case Eclipse)
  • Create a java project.
  • Add the selenium-java-.jar files to your project buildpath.
  • Write your Selenium test in Java using the selenium-java-client API. The API is presented later in this chapter.
  • Run Selenium server from the console.
  • Execute your test from the Java IDE or from the command-line.
Note: For details about how to configure selenium rc with eclipse go through the link Configuring Selenium RC With Eclipse.