Working with Pop Up Windows in Selenium

Posted By: Matthew Sneeden

Like many applications, users commonly interact with popup windows in the normal use of Fellowship One.  Creating test scripts that interact with popup windows posed an interesting problem due to Selenium’s handling of popup windows.  If the popup in question exists as a child browser window (and not a simple alert prompt), Selenium commonly loses its association with the main application window after clicking on a control on a popup window.  As a result, an error occurs when the user attempts a WaitForPageToLoad command after returning to the main window.

This will result in an error stating that the current frame or window is closed…

selenium.WaitForPopUp("psuedoModal", "30000");
selenium.SelectWindow("name=psuedoModal");
selenium.Click("btnYes");
selenium.SelectWindow("");
selenium.WaitForPageToLoad("30000"); 

Instead of interacting with the controls on the popup menu via a Click command use a KeyPress command specifying a JavaScript keycode for Enter (\\13).

This details the workaround allowing the user to complete the same interaction avoiding the error…

selenium.WaitForPopUp("psuedoModal", "30000");
selenium.SelectWindow("name=psuedoModal");
selenium.KeyPress("btnYes", "\\13");
selenium.SelectWindow("");
selenium.WaitForPageToLoad("30000"); 

Matthew Sneeden is a member of the Quality Assurance team at FT.  He takes part in a wide array of testing activities ranging from in-sprint to regression, and manual to automated.  He also takes part in feature discussions and helps identify candidate content for future standards documents to help better serve our clients.

Posted In: Tips,

Comments:
No one has commented yet. Be the first!
Commenting is not available in this channel entry.

Categories:

Previous Posts:


Subscribe to the RSS feed!