Wednesday, February 2, 2011

PopUp Handling using Selenium RC and Testng

PopUp Handling using Selenium Rc


Objective:- To create a script for handling popup using Selenium TestNG.


Procedure: As follows

Step 1: Create a script for a website which consists of popup like http://www.blazonry.com/javascript/windows.php

Step 2: The main functions we use to handle popup are

selenium.selectWindow(“”);

selenium.Focus();

selenium.selectWindow: This is used for selecting the window or popup which appears by clicking.

selenium.Focus() : This is used for focusing on the window that means the control shifts to the window (popup) from the main page.

selenium.selectWindow(“null”) : This command is used for getting the control from popup window to the neutralize . So that it can focus on other window.


Here is the example for popup handling


@Test
public void popup() throws Exception {

selenium.open("http://www.blazonry.com/javascript/windows.php");

selenium.click("//p[4]/a/b");

selenium.waitForPopUp("Window1", "30000");

selenium.selectWindow("name=Window1");

selenium.click("link=Close this Window");

Thread.sleep(50000);

selenium.selectWindow("null");

selenium.click("//p[10]/a/b");

selenium.waitForPopUp("Window2", "30000");

Thread.sleep(30000);

selenium.selectWindow("name=Window2");

selenium.click("link=Click Here to Change the Focus");

Thread.sleep(50000);

selenium.selectWindow("null");

selenium.click("link=close Window 2 from this link");

Thread.sleep(30000);

}

And the selenium file attached should has the following code:



suite name="My suite" thread-count="1"

parameter name="seleniumPort" value="4444"
parameter name="seleniumHost" value="localhost"
parameter name="webSite" value="http://www.gmail.com"
parameter name="browser" value="*iexplore"
test name="Simple example"

The above all code should be written with in the < > braces.





6 comments:

  1. Official Selenium Blog
    July 20, 2012
    A Smattering of Selenium #103
    Filed under: Uncategorized — adam goucher @ 2:07 pm

    Seems I had this all ready to go yesterday… oh, and Happy Birthday Jim Evans — maintainer of IE and C# driver. If also a day late.

    Migrating Unit Tests from Selenium to Watir Webdriver is less about migrating rather than a quick overview of Watir
    HttpWatch 8.4: Supports Firefox 14 and Selenium appears to be http traffic monitor — minus a proxy
    sms is a quick script which will send an sms from the commandline — using Se as the means of doing it
    Buster.JS comes at you from the new-and-shiny factory
    Javascript testing in parallel with WD.js and Selenium – mmmm parallel.
    The Pain of HTML5 – So. When does the backlash against HTML5 start?
    Acceptance Testing: Asserting Sort Order shows how they checked that certain fields followed other ones
    Mina is also from the new-and-shiny pile, but for deployment of applications. Also in the ‘we don’t like cap/vlad so wrote our own’ pile.
    Why I don’t like factory_girl — This story is one of Ruby groupthink gone awry
    Selenize looks like another Se-in-the-cloud, but tightly coupled to Github

    ReplyDelete
  2. ALE EEE KAHA HAI RE .....................

    ReplyDelete
  3. BIHAR BABU KO KOI SAMJHA DIYE SELENIUM...BHAGWAN BHALA KARE TUMHAAR...

    ReplyDelete
  4. KOY KOY KOY KOY KOY

    ReplyDelete
  5. Amazing, thanks a lot my friend, I was also siting like a your banner image when I was thrown into Selenium.
    When I started learning then I understood it has got really cool stuff.I can vouch webdriver has proved the best feature in Selenium framework.Thanks a lot for taking a time to share a wonderful article.

    Best Selenium Training Institute in Chennai
    Selenium Training in Velachery

    ReplyDelete