Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I use selenium 1 and it works well to handle popups in my application. </p> <pre><code> //Click on browse file button, open a popup selenium.click("//input[@value='Browse...']"); //waiting for popup to load selenium.waitForPopUp("_Dialog", "30000"); //selecting the popup by passing window name selenium.selectWindow("name=_Dialog"); //click a link inside pop up window selenium.click("link=something"); //Put other popup operations here //click cancel button for pop up selenium.click("cancel"); //back to main window selenium.selectwindow("null") </code></pre> <p>To get the message from alert boxes, use <code>selenium.getAlert();</code>. This will return the message contained in the alert box as String. </p> <p>Also, sometime you will need to check, whether alert has occurred before switching to it.</p> <pre><code> int noofWindows = selenium.getAllWindowNames().length; if (noofWindows &gt; 1){ //selects the second window selenium.selectWindow(selenium.getAllWindowIds()[2]); //Prints the message in the alert window System.out.println(selenium.getAlert()); } </code></pre> <p>If it is not a necessity to run test in IE, use firefox(*chrome) and close all other windows before executing the code. </p> <p>I hope this helps you.</p> <p>*All the mentioned code is for handling JavaScript pop-ups. I'm not sure whether this will work for Vb-script or not.</p> <p><strong>EDIT</strong></p> <p>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.</p> <p>AutoIT script should be something similiar to </p> <pre><code>WinWaitActive(windowTitle) ControlClick(windowTitle,"",buttonName) </code></pre> <p>and save it as IEsave.exe. NOTE: I'haven't tried this AutoIT script.</p> <p>now you have execute IEsave.exe from your program. I'm using java here.</p> <pre><code>java.lang.Runtime.getRuntime().exec("c:/IEsave.exe"); </code></pre> <p>This will execute the file which in-turn will handle the save button event for windows.</p> <p>You can create similar exe files for handling other window's events.</p> <p>Hope this solves your problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload