What is Selenium RC?
Selenium Remote Control (RC) was the primary Selenium venture that supported for quite a while before Selenium WebDriver(Selenium 2.0) appeared. Presently Selenium RC is scarcely being used, as WebDriver offers all the more remarkable highlights, anyway clients can in any case keep on creating contents utilizing RC.
It permits us to compose mechanized web application UI tests with the assistance of full intensity of programming dialects, for example, Java, C#, Perl, Python and PHP to make progressively complex tests, for example, perusing and composing records, questioning a database, and messaging test results.
Selenium RC Architecture
Selenium RC works so that the customer libraries can speak with the Selenium RC Server passing every Selenium order for execution. At that point the server passes the Selenium order to the program utilizing Selenium-Core JavaScript orders.
The program executes the Selenium order utilizing its JavaScript translator.
Selenium RC comes in two sections.
- The Selenium Server dispatches and executes programs. Notwithstanding that, it deciphers and executes the Selenese orders. It likewise goes about as a HTTP intermediary by catching and checking HTTP messages went between the program and the application under test.
- Customer libraries that give an interface between every last one of the programming dialects (Java, C#, Perl, Python and PHP) and the Selenium-RC Server.
RC Scripting
Presently let us compose an example content utilizing Selenium Remote Control. Let us use http://www.calculator.net/for understanding Selenium RC. We will play out a Percent count utilizing 'Percent Calculator' that is available under the 'Math Calculators' module.
Stage 1 − Start Selenium Remote Control (with the assistance of order brief).
Stage 2 − After propelling Selenium RC, open Eclipse and make "Another Project" as demonstrated as follows.
Stage 3 − Enter the undertaking name and snap 'Next' button.
Stage 4 − Verify the Source, Projects, Libraries, and Output organizer and snap 'Finish'.
Stage 5 − Right snap on 'venture' compartment and pick 'Arrange Build Path'.
Stage 6 − Properties for 'selrcdemo' opens up. Explore to 'Libraries' tab and select 'Include External JARs'. Pick the Selenium RC container document that we have downloaded and it would show up as demonstrated as follows.
Stage 7 − The referenced Libraries are appeared as shown underneath.
Stage 8 − Create another class record by playing out a correct snap on 'src' organizer and select 'New' >> 'class'.
Stage 9 − Enter a name of the class record and empower 'open static void fundamental' as demonstrated as follows.
Stage 10 − The Created Class is made under the organizer structure as demonstrated as follows.
Stage 11 − Now it is the ideal opportunity for coding. The accompanying code has remarks implanted in it to cause the perusers to comprehend what has been advanced.
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();
// Click on Link Math Calculator
selenium.click("xpath = .//*[@id = 'menu']/div[3]/a");
Thread.sleep(2500); // Wait for page load
// Click on Link Percent Calculator
selenium.click("xpath = .//*[@id = 'menu']/div[4]/div[3]/a");
Thread.sleep(4000); // Wait for page load
// Focus on text Box
selenium.focus("name = cpar1");
// enter a value in Text box 1
selenium.type("css=input[name = \"cpar1\"]", "10");
// enter a value in Text box 2
selenium.focus("name = cpar2");
selenium.type("css = input[name = \"cpar2\"]", "50");
// Click Calculate button
selenium.click("xpath = .//*[@id = 'content']/table/tbody/tr/td[2]/input");
// verify 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");
}
}
}
Stage 12 − Now, let us execute the content by clicking 'Run' Button.
Stage 13 − The content would begin executing and client would have the option to see the order history under 'Order History' Tab.Stage 14 − The last condition of the application is appeared as beneath. The rate is determined and it showed the outcome on screen as demonstrated as follows.
Stage 15 − The yield of the test is imprinted on the Eclipse support as appeared underneath as we have printed the yield to the comfort. Continuously the yield is kept in touch with a HTML record or in a straightforward Text document.