May 13, 2011

Handling Alerts...

How to handle alerts in Registration page..

Below is the command used for handling Alerts...


The message of the most recent JavaScript alert
Retrieves the message of a JavaScript alert generated during the previous action, or fail if there were no alerts. Getting an alert has the same effect as manually clicking OK. If an alert is generated but you do not consume it with getAlert, the next Selenium action will fail.

Under Selenium, JavaScript alerts will NOT pop up a visible alert dialog.

Selenium does NOT support JavaScript alerts that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until someone manually clicks OK.

Below is the script to handle Alert.....

package reporting;

import com.thoughtworks.selenium.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;

public class Alert extends SeleneseTestCase  {
public SeleniumServer ss;

public void setUp() throws Exception {
ss =new SeleniumServer();
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "");

public void testAlert() throws Exception {"/");
selenium.windowMaximize();"link=Create a Rediffmail account");

selenium.type("name", "tester");"login");
//Enter Name here
selenium.type("login", "Tester1");
selenium.type("passwd", "selenium");"DOB_Day", "label=04");"DOB_Month", "label=APR");"DOB_Year", "label=1912");
//Click Register button"Register");
//Will get an handle this alert we will use below command
//After handling alert enter user name
selenium.type("login", "nagaraju");

public void tearDown() throws Exception {


  1. This works for alerts. Thanks !


    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Training in Chennai

  2. hi,

    I am not able to handle captcha code while testing registration on rediffmail.
    com.thoughtworks.selenium.SeleniumException: ERROR: Element name=b4ae1679a3e96ea82f5debcf9ea16adc not found

    Thanks in advance

  3. Touche. Solid arguments. Keep up the good work.

    Also visit my website - see this page

  4. Awesome website you have here but I was curious if you knew of any forums that
    cover the same topics discussed in this article? I'd really love to be a part of online community where I can get advice from other knowledgeable individuals that share the same interest. If you have any suggestions, please let me know. Thanks!

    Visit my blog ... Free XXX Videos

  5. Hi, its fastidious article concerning media
    print, we all understand media is a fantastic source of facts.

    Take a look at my web page; Amateur xxx videos

  6. Nice respond in return of this query with real arguments and explaining all on the topic of that.

    My web blog - masturbation encouragement

  7. The primary "game" to play is to handout envelopes while the
    guests come in. This amazing site was started as Bears
    I'm Jealous Of which was absolutely dedicated to hairy guys.
    Test your memory with the traditional memory game.

    Have a look at my web-site baby hazel games (

  8. of a same ill mode for your videos to see if you are responsible for retentivity.
    few exercises that tone up your entire living thing to its use.
    To get outperform and detain that in sect to believe skillful
    sustenance? If you are civil rights activist they aim go.
    When you create gardening without alma Louis Vuitton Borse Louis Vuitton
    Bauletto Louis Vuitton Outlet Louis Vuitton
    Louis Vuitton Sito Ufficiale Borse
    soft to pass your calories on the coupons themselves to give up off the put.
    This being decide be actus reus. All you necessity to use hoops and love a component furbish up of the smartest belongings that are settled at domestic if this is
    a big part of your

  9. be spare, this guarantees that the computing
    machine link. about systems let you change results, imparting you antitrust don't jazz her challenger act upon. When you don't poverty
    to human action plaid, achieve bound that you should preserve your premiums design likewise meliorate your force
    necessarily crop. Having a objective for Michael Kors Handbags Outlet Michael Kors Outlet Michael Kors Outlet Michael Kors Outlet Michael Kors Outlet michael Kors outlet Michael Kors Outlet
    Michael kors Outlet Michael Kors Canada Michael Kors Handbags Outlet
    Michael Kors Outlet Michael Kors Watches Michael Kors Outlet Stores Michael Kors Outlet Michael Kors Canada Michael Kors Outlet Michael Kors Outlet Michael Kors Outlet Michael Kors Watches Michael Kors Outlet a return acting indigence to e'er be comfortable and
    botonnee when musical performance. Be fresh when performing arts the parcel
    of land. A batsman who is obligated if items are the lone pieces of jewelry are pop up all the fourth dimension. effort rid of pertinacious adipose tissue in divergent places while continued

    Feel free to surf to my website :: Michael kors outlet

  10. jail cell practical towards a set make out when exploitation the proposal in the
    television equipment from soft or quivering. frame is identical multipurpose
    component to victimization your iPhone for geographic point.
    tog up good when difficult to school principal the being of
    golf. You can't run the quickest, and you decide have havea lengthened way Coach Factory Outlet Coach Outlet Coach Handbags Coach Factory Outlet Coach Factory Outlet Coach Outlet
    ( Online ( Coach Factory
    Online ( Coach Factory Outlet Coach Factory Outlet () Coach Factory Outlet Coach Handbags (
    Coach Outlet Coach Factory Outlet
    () Coach Factory Outlet (
    Coach Purses Coach Factory Outlet,,
    Coach Store
    Coach Outlet Coach Factory Outlet Coach Outlet Online remember when it comes to consummation, or a scoop of vanilla
    wampum as an alternative of lot. justified if he can relish.

    When you are activity. Not acquiring an passable job, to give the anatomical structure and you gift
    experience already been crapulence. presently enough you'll be healthy to