Window Dialogs & Popup handling in Java or Javascript

I need to manipulate Popups & Download Dialogs of IE browser using either Java or Javascript based automated solution.

I tried with selenium2 but its not working properly so any other suggestion for the same. Actually selenium2 does not provide proper handling of alert/download dialogs so I am thinking to use some other javascript/java solution.

With Download Dialog: I need to save the downloaded file to particular location. With Alerts Dialogs: I need to check the displayed message and click on the particular button.

Any suggestion is appreciated. Thanks.



I use selenium 1 and it works well to handle popups in my application.

    //Click on browse file button, open a popup"//input[@value='Browse...']");

    //waiting for popup to load
    selenium.waitForPopUp("_Dialog", "30000");

    //selecting the popup by passing window name

    //click a link inside pop up window"link=something");

    //Put other popup operations here

    //click cancel button for pop up"cancel");

    //back to main window

To get the message from alert boxes, use selenium.getAlert();. This will return the message contained in the alert box as String.

Also, sometime you will need to check, whether alert has occurred before switching to it.

        int noofWindows = selenium.getAllWindowNames().length;
        if (noofWindows > 1){
        //selects the second window 
        //Prints the message in the alert window

If it is not a necessity to run test in IE, use firefox(*chrome) and close all other windows before executing the code.

I hope this helps you.

*All the mentioned code is for handling JavaScript pop-ups. I'm not sure whether this will work for Vb-script or not.


I think IE download pop up is a windows event so cannot be handled by selenium directly, for this you'll have to use Java AWT or AutoIT.

AutoIT script should be something similiar to


and save it as IEsave.exe. NOTE: I'haven't tried this AutoIT script.

now you have execute IEsave.exe from your program. I'm using java here.


This will execute the file which in-turn will handle the save button event for windows.

You can create similar exe files for handling other window's events.

Hope this solves your problem.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.