Selenium RC

Selenium RC

Table of Contents

Selenium RC is a main selenium project which is sustained for a longer period of time before the selenium WebDriver which came into existence. The Selenium RC will be in use as webDriver provides strong features and continue to develop the scripting using the RC. It provides to code the command for automated web application UI tests supports full power of programming languages like java, C#, perl and python create more complex tests read write operations on files, querying a database and emailing test results.

Selenium RC Architecture

Selenium RC will work in such a way that the client libraries will communicate with all the selenium RC Server that is passing with each Selenium command to the browser using Selenium core is JavaScript commands.

The browser will run the selenium commands using its JavaScript interpreter

Selenium IDE 52

Selenium RC will come into the parts:

  • The Selenium Server will launch and kills browsers. It interprets and executes the selenese commands. There are properties of HTTP proxy by intercepting and validating HTTP messages forwarded between the browser and application which is under test.
  • There are client libraries has interface between one programming languages and the  other as Selenium RC server.

RC scripting:

Consider a sample script using Selenium Remote Control. When we use http://www.calculator.net/ for knowing Selenium RC. We can calculate using ‘Percent calculator’ the present under the ‘Math Calculators’ module.

Step 1: Start selenium Remote control.

Step 2: When launching Selenium RC, we have to open Eclipse and create a “New Project” as 

Selenium IDE 53

Step 3: We have to enter the project name and click “Next” button.

Selenium IDE 54

Step 4: Verify the source project,libraries and output folder and click “finish”.

Step 5: By right clicking on the project we choose to “Configure build path”

Step 6: Properties for ‘selrcdemo’can be used up. These transfer to ‘Libraries’ tab and click ‘Add external JARs. Select the selenium RC jar file we have downloaded and it would appear.

Step 7: The referenced Libraries which are shown 

Selenium IDE 58

Step 8: It is used to create new class file by performing a ‘right click’ on ‘src’ folder and select ‘New’>>’class’.

Step 9: We enter the name of the class file and also enable ‘public static void main’.

Step 10: It has Class is created under the folder structure.

Step 11: Now it is time for coding. The following code has comments that are embedded in it to make the readers understand has been put forth.

Package selrcdemo;

Import com.thoughtworks.selenium.DefaultSelenium;

Import com.thoughtworks.selenium.Selenium;

public class rcdemo {

   public static void main(String[] args) throws InterruptedException // This is Main function

{

      Selenium selenium1 = new DefaultSelenium(“localhost”, 4444 , “Mozilla Firefox”, “http://www.Calculator.net”);      // Instatiate the RC Server

      selenium1.start();   // Start

      selenium1.open(“/”);  // Open the URL

      selenium1.windowMaximize();

      // Click on Link Math Calculator

      selenium1.click(“xpath = .//*[@id = ‘menu’]/div[3]/a”);

      Thread.sleep(2500); // Wait for page load

      // Click on Link Percent Calculator

      selenium1.click(“xpath = .//*[@id = ‘menu’]/div[4]/div[3]/a”);

      Thread.sleep(4000); // Wait for page load

      // Focus on text Box

      selenium1.focus(“name = cpar1”);

      // enter input in Text box 1

      selenium1.type(“css=input[name = \”cpar1\”]”, “10”);

      // enter a input Text box 2

      selenium1.focus(“name = cpar2”);

      selenium1.type(“css = input[name = \”cpar2\”]”, “50”);

      // Click Calculate button

      selenium1.click(“xpath = .//*[@id = ‘content’]/table/tbody/tr/td[2]/input”);

      //  By verify if the result is 5

      String result = selenium1.getText(“.//*[@id = ‘content’]/p[2]”);

      if (result == “5”) {

         System.out.println(“Pass”);

      } else {

         System.out.println(“Fail”);

      }

   }

}

Step 12 – We will  execute the script by clicking ‘Run’ Button.

Selenium IDE 72

Step 13: Here the script will be starting to run and the user will be able to see that the command history under the ‘Command History’ Tab.

Step 14: The final state of the application is shown. The percentage will be calculated and it is displayed the result  on screen.

Step 15: The output is tested will be printed on the Eclipse console as shown below as we  have printed output  to console.In real  time the output to an HTML file or a simple Text file.

Selenium IDE 74

Questions

  1. Explain Selenium RC?
  2. Explain the Architecture and advantages of Selenium RC?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this article
Subscribe
By pressing the Subscribe button, you confirm that you have read our Privacy Policy.
Need a Free Demo Class?
Join H2K Infosys IT Online Training
Enroll Free demo class