QTP -Testcomplete-Testing-Loadrunner-Selenium-Blog

Selenium IDE RC -Remote Control Scripting

Posted in SELENIUM RC by Sandy runner on January 25, 2010

Xpather for all Version : Download here 

Selenium  Overview:-

Selenium is a suite of tools to automate web app testing across many platforms. It is a GUI based automation tool. Initially it is built by ThoughtWorks. It supports various browsers on various platforms

Selenium Projects
Selenium has many projects. Following projects are mostly used by testers.

  1. Selenium IDE (IDE)
    Selenium IDE can be used only in FireFox. It is an add-on for FireFox. User can record the actions and can edit and debug the tests. It can be used to identify IDs, name and XPath of objects. Only one test at a time.
  2. Selenium Core (CORE)
    Selenium Core is the original Javascript-based testing system. This technique should work with any JavaScript enabled browser. It is the engine of both, Selenium IDE and Selenium RC (driven mode), but it also can be deployed on the desired application server. It is used specifically for the acceptance testing.
    User can record the tests using Selenium IDE and can use the same tests to run in other browsers with minimal modifications. It provides support to run the tests in HTA (HTML Applications) Mode. This mode works only in IE.
  3. Selenium Remote Control (RC)
    Selenium Remote Control is a test tool that allows user to write automated web application UI tests in few programming languages against any HTTP website using any mainstream JavaScript-enabled browser. User can write the tests (More expressive programming language than the Selenese HTML table format) in Java, DotNet, Perl, Ruby and PHP. Also it supports few testing frameworks.
  4. Selenium Grid
    Selenium Grid allows easily to run multiple tests in parallel, on multiple machines, in an
    heterogeneous environment by cutting down the time required for test execution. Using this, user can run multiple instances of Selenium Remote Control in parallel.

Supported browsers
Selenium tools can run in following browsers.

  • Internet Explorer
  • FireFox
  • Opera
  • Safari
  • Seamonkey

Supported Operating Systems
Users can execute the selenium tests in following OS.

  • Windows
  • Linux
  • Solaris
  • OS X

Supported Programming languages
Below languages are supported by Selenium RC.

  • C# (DotNet)
  • Java
  • Perl
  • Ruby
  • Python
  • PHP

Sample Code

This is not perfect code : The following code needs many improvements but its a good starting point for you 

Following program  tells how to launch a browser and to play around with text,list,combobox  objects we find normally in any website

package Orkut;
import com.thoughtworks.selenium.*;
import com.thoughtworks.selenium.DefaultSelenium;

public class MySelenium {
static Selenium selenium;
static boolean val,val1;
public static void main(String arg[]) throws Exception
{
selenium = new DefaultSelenium("localhost",
4444, "*iexplore", "http://www.ge.com");

selenium.start();

Thread.sleep(4000);

selenium.windowMaximize();
selenium.windowFocus();
selenium.open("/index.html");

selenium.click("//div[@id='ge_footer']/ul/li[2]/a");

val=selenium.isElementPresent("//img[@alt='GE: imagination at work']");
for (int second = 0;second<=10; second++) {
    val=selenium.isElementPresent("//img[@alt='GE: imagination at work']");

     if (val)

     {
         System.out.println(val);
         break;
     }
     else
     {

         if (second==10)
         {
             System.out.println("Page not found :=GE: imagination at work");
             selenium.stop();

         }
         Thread.sleep(4000);
     }

    }

selenium.click("//ul[@id='ge_secondaryNav']/li[2]/a");

val1=selenium.isElementPresent("//div[@id='secondary_content']/div/h3");

for (int second = 0;second<=10; second++) {
    val1=selenium.isElementPresent("//div[@id='secondary_content']/div/h3");

     if (val1)
     {
         System.out.println(val1);
         break;
     }
     else
     {

         if (second==10)
         {
             System.out.println("Element not found :=GE: Other Contact Resources");
             selenium.stop();

         }
         Thread.sleep(4000);
     }

    }

selenium.click("//input[@id='contact_type_press']");
selenium.select("//select[@id='contact_subject']", "label=Other");
selenium.select("//select[@id='contact_country']", "label=Algeria");
selenium.type("//input[@id='contact_email']", "abc@vvv.com");
selenium.type("//textarea[@id='contact_comments']", "testing");

//selenium.click("//form[@id='contact_form']/p/input");

}

}

Advertisements

2 Responses

Subscribe to comments with RSS.

  1. romee said, on January 25, 2010 at 2:14 pm

    thanks, its good code, i’ll do it

  2. krishna said, on April 21, 2010 at 5:08 am

    hey santhosh .. can u plzz tell me how to close the child window in IDE


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: