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) { myform.removeAttr('target'); } myform.submit(); then my selenium script would tell the page that we are selenium BEFORE clicking on the link. <tr> <td>storeEval</td> <td>this.browserbot.getUserWindow().myproject.selenium=true</td> <td></td> </tr> <tr> <td>clickAndWait</td> <td>link=Link That Opens New Window</td> <td></td> </tr> Voila! Now I can assert and do all sorts of stuff on the current page. References:
|
SearchDrupal ContributionsMake a Payment to Christian Roy |
Post new comment