Selenium Testing - SPLessons

Selenium RC Architecture

Home > Lesson > Chapter 8
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Selenium RC Architecture

Selenium RC Architecture

shape Description

Selenium RC Architecture - Selenium RC is also known as Selenium 1. RC is nothing but Remote Control. RC is having the authority to control the entire system. It can Automate the entire application. The aim of RC is handling server. It is responsible to serve all the requests. Selenium Remote Control is a take a look at apparatus that permits the developer to compose automated internet application UI tests in any programming dialect such as Java, Python, C++, etc..to make greater vital tests, as an example, perusing and composing documents and messaging test comes about. selenium internet driver is like extension to Selenium RC.

shape Conceptual Figure

Following is the Selenium RC Architecture . Selenium RC works in a way that the purchaser libraries can chat with the Selenium RC Server passing every Selenium summon for execution. At that issue the server passes the Selenium request to the utility making utilization of Selenium-center JavaScript summons.

Selenium Server

  • It is the code that drives the client browser.
  • It will inject selenium framework into the browser.
  • Selenium Server speaks with the running test client and handles the browser.
  • It gives back the result to the client.
  • HTTP GET and POST methods are used to provide communication between server and client.

Client libraries

Selenium RC Architecture - Client libraries gives the API to application assessments and execute them on the server, each utilization gives entry to all Selenium instructions, bolstered API usage exists in some languages reminiscent of follows.
  • Ruby
  • Phython
  • Perl
  • JAVA
  • .NET

shape Step 1

Before going to start the scripting, first the developer need to set the eclipse, Open the Eclipse and start New Java Project, and click on Next button.

shape Step 2

Write the project Name and press Next button. here the developer has given the name Selrc demo.

shape Step 3

In the below window select Selrc Demo and press Finish button. When the developer created the project name, after finishing the task automatically project will be created with source file where user need to write class files and insert package names.

shape Step 4

From package explorer choose Selrcdemo. A Java package is a Framework for sorting out Java classes into namespaces like the modules of Modula, giving disconnected programming in Java. Java groups can be secured in compacted reports called JAR records.

shape Step 5

Right click on package container select configure build path. Here user has to add jar files which are supported to the code to vanish the errors and jar files will contain the group of instructions.

shape Step 6

After completing the above now it's time to Create a New class by clicking src here given the class name as rcdemo.

shape Step 7

Enter the below Code in the eclipse. rcdemo.java [java] package selrcdemo; import com.thoughtworks.selenium.DefaultSelenium; import com.thoughtworks.selenium.Selenium; public class rcdemo { public static void main(String[] args) throws InterruptedException { // Instatiate the RC Server Selenium selenium = new DefaultSelenium("localhost", 4444 , "firefox", "http://www.calculator.net"); selenium.start(); // Start selenium.open("/"); // Open the URL selenium.windowMaximize(); // Press on Link Math Calculator selenium.click("xpath=.//*[@id='menu']/div[3]/a"); Thread.sleep(2500); // Wait for page load // Press on Link Percent Calculator selenium.click("xpath=.//*[@id='menu']/div[4]/div[3]/a"); Thread.sleep(4000); // Wait for page load // Concenrate on text Box selenium.focus("name=cpar1"); // Give a value in Text box 1 selenium.type("css=input[name=\"cpar1\"]", "10"); // Give a value in Text box 2 selenium.focus("name=cpar2"); selenium.type("css=input[name=\"cpar2\"]", "50"); // Press Calculate button selenium.click("xpath=.//*[@id='content']/table/tbody/tr/td[2]/input"); // Check if the result is 5 String result = selenium.getText(".//*[@id='content']/p[2]"); if (result == "5"){ System.out.println("Pass"); } else{ System.out.println("Fail"); } } } [/java] As of now discussed Selenium will be opened in Firefox so to connect to the Firefox the developer supposed to give port number as follows. [java]Selenium selenium = new DefaultSelenium("localhost", 4444 , "firefox", "http://www.calculator.net");[/java] Where the developer provided on web site insted of that developer can perform other web sites to check whether the test is passed or not. Here the developer has written the code to open the URL and to maximize the window if the test is passed. [java] selenium.start(); // Start selenium.open("/"); // Open the URL selenium.windowMaximize(); [/java] Sleep method is used to sleep the thread for a particular interval of time. [java]Thread.sleep(4000);[/java]

shape Step 9

The output can be visible as follows. Where if the the result is 5 then test will be as follows otherwise test will be failed, instead of this web site directly if the developer redirected to google then browsing page will be opened.

Summary

shape Key Points

  • Selenium Remote Control is the old strategy, now every one is using web driver.
  • Mobile Applications can not be supported by Selenium RC.
  • The Selenium is freeware, portable tool and open source.
  • By using Selenium web driver user can test Android, Blackberry, Apple.
  • The Selenium only supports web based applications not to window based applications.