Selenium RC

Free Selenium Tutorials and Videos


Note:  Double click on Selenium training video to fit to screen

Details

Selenium RC is the old version of selenium. Its powerful but has many issues as well.
The core engine of selenium RC is is based on javascript(similar to IDE). Selenium RC can be implemented in many languages such as:
- Ruby
- Java
- Pearl
- C#
- Python
- PHP

This makes it very powerful as you can write your test scripts using any one of the languages. The language you select to write your selenium tests is independent of the language in which your website is developed.

Selenium Server

Selenium RC relies on the jar file called selenium-server.jar. This jar files gets downloaded when you download selenium. RC server resides in this jar file. So when working with selenium RC the first thing you need to do is that you need to start the selenium server. Selenium server can be started with following command from command prompt:
java -jar selenium-server.jar

Before giving this command make sure that you are the location of this jar file on the command prompt. Selenium server runs on the port number 4444 of your PC.

The other way to start the selenium server is through code. In java, you can start the selenium server by creating the object of the class called SeleniumServer. The code looks like this;
SeleniumServer server = new SeleniumServer(); server.boot(); server.start();

Server can be stopped with the command in RC- server.stop(); This will also close any browser opened by selenium.

Initializing selenium Object

Once the server has been started, we can initlize the selenium object in 2 ways.
This first way is that your class should extend an inbuilt class in API known as SeleneseTestCase. Code looks like this.

public class MyTestClass extends SeleneseTestCase{


@Test
public void testApp(){

setup("http://google.com","*firefox"); // testsite name , browser type

}

}
This inittializes the selenium RC object and you can use it to write your selenium scripts / selenium tests.

The second way is to use DefaultSelenium class. This is an inbuilt class ins Selenium RC API.
Code looks like this:

Selenium selenium = new DefaultSelenium("localhost",4444,"*firefox","http://www.w3schools.com");

The selenium object is intitialzed this way.. Locahost is your PC, 4444 is the port number on which selenium server runs.
Firfox will be the browser and the last argument in constructor is URL of the test site.