views:

53

answers:

2

Hi!

I've been playing with Selenium lately, trying to create tests for an IE only application. Things were progressing (though slowly as without the recorder plugin I had to resort to trial and error to try to find the appropriate element paths), but now I'm stuck with a problem related to popup menues.

Most of the application actions are triggered from a popup menu created with javascript window.createPopup() and I can't seem to find a way to send events to elements inside the popup.

Maybe I should be selecting the popup like I do for windows opened with window.open(...), which are working fine BTW. I tried assigning a name to the popup menu returned by createPopup() and treating it the same way I treat windows but that doesn't seem to be working.

Does anybody knows if this is supposed to work? Any help will be appreciated.

Thanks,

A: 

if you know the name of the window you can do

selenium.click("elementToLaunchPopup");
selenium.waitForPopup("nameOfWindow",30000);
selenium.selectWindow("nameOfWindow");
// rest of your test

To get back to the main window you will need to selenium.selectWindow("null");

AutomatedTester
Hi, that does not work, becuase the popups created with Window.createPopup() do not allow to specify a name. It's not like the regular window.open function. It's something related with the creation of HTML dynamic and it's a feature that only applies to IE.
Kari
You can also try getAllWindowIds and then loop through them to find your window. Popups are notoriously hard to work with.
AutomatedTester
+1  A: 

Unfortunately, no. window.createPopup isn't accessible to Selenium. Being an IE only feature it has really limited portability and generally isn't a best practice. I know that's of little consolation to you, because I assume your stuck with someone else's code that's used createPopup.

The real problem is that craeatePopup doesn't add anything to the DOM. Try opening a popup object and viewing it's source. You'll see this:

<html><body></body></html>

So there's nothing really there for Selenium to grab hold of.

What does the popup do for your application? You indicated it provides some navigation, can you just navigate to those pages directly?

pnewhook
yes, as you mention, I'm stuck in someone else code. :) The popup is kind of right click menu, this menu is created with this Windows.CreatePopup method. And the navigation it provides is based on the element you had right-clicked, so I cannot navigate it directly. I'm trying to find out a way to do it, but it seems that it does not exists. Thank you!
Kari