Selenium and popups.

I wanted to write a selenium test script to validate calculation done in a page to make sure they match those of another page. I used the store* functions to grab the values from the source. My problem was that the second page was actually a popup.

There have been some reported problems with selectWindow and selectPopup and waitForPopup functions. They are not always working with Firefox 3.x. They were not working for me.

So I thought that maybe I could have the page NOT popup when it's being accessed by selenium. That way I will not have to use these broken functions.

The link that I was clicking on was running some javascript(jquery) that were changing the form's action and target. I've modified it to detect if we are coming from selenium and REMOVE the target. This would mean the result would show up in our current window instead of a popup window.

var myproject = {};
var myform = $('#myformid');
myform.attr('action' , '/some/new/destination').
  attr('target' , 'some_target');
if(myproject.selenium == true) {

then my selenium script would tell the page that we are selenium BEFORE clicking on the link.

        <td>link=Link That Opens New Window</td>

Voila! Now I can assert and do all sorts of stuff on the current page.


Your information about

Your information about selenium is really interesting. Also I want to know the latest new techniques which are implemented in Selenium. Please update it in your website.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options