21

We are running Selenium regression tests against our existing code base, and certain screens in our web app use pop-ups for intermediate steps.

Currently we use the commands in the test:

// force new window to open at this point - so we can select it later
selenium().getEval("this.browserbot.getCurrentWindow().open('', 'enquiryPopup')");
selenium().click("//input[@value='Submit']");
selenium().waitForPopUp("enquiryPopup", getWaitTime());
selenium().selectWindow("enquiryPopup");

...which works most of the time. Occasionally the test will fail on the waitForPopUp() line with

com.thoughtworks.selenium.SeleniumException: Permission denied

Can anyone suggest a better, more reliable method?

Also, we primarily run these tests on IE6 and 7.

brasskazoo
  • 76,030
  • 23
  • 64
  • 76
  • 2
    What the hell IS it with this thread? There are 5 different people down below trying to hijack it! – ryeguy Oct 22 '09 at 21:26

5 Answers5

4

It works!! Just to make it easier for the folks who prefer selenese.

This worked for me using IE7(normal mode).

What a freaking hassle. Thank the spaghetti monster in the sky for SO or there is no way I would have got this working in IE.

<tr>
    <td>getEval</td>
    <td>selenium.browserbot.getCurrentWindow().open('', 'windowName');</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>buttonName</td>
    <td></td>
</tr>
<tr>
    <td>windowFocus</td>
    <td>windowName</td>
    <td></td>
</tr>
<tr>
    <td>waitForPopUp</td>
    <td>windowName</td>
    <td>3000</td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>windowName</td>
    <td></td>
</tr>
branchgabriel
  • 4,241
  • 4
  • 34
  • 48
  • This doesn't work for me unless I move windowFocus to the last command issued. It doesn't make any sense for it to be before the waitForPopUp, does it? – Chris Noe Dec 29 '09 at 18:26
1

If you are running in *iehta mode then you are going to run into some glitches here and there. We run Selenium at my job and there seem to be lots of issues with IE and AJAX.

However, it sounds like the issue you are running into is one where Selenium is trying to access a component in another window before it completely loads up. I am not sure what your default timeout range is set to, but you may want to try increasing it to 60 (60000ms) seconds or so to get past the issue.

Other than that I would suggest running your tests in Firefox (using *chrome) as it produces much more reliable results, but sometimes it is simply not possible due to business requirements.

Josh
  • 44,706
  • 7
  • 102
  • 124
  • Oh believe me, I wish we could just run it in firefox! But 99% of our users are on IE so that is the priority for testing... We use *iexplore, not *iehta too. I'm not aware of the differences? – brasskazoo Sep 19 '08 at 03:18
  • *iehta and *chrome allow for https support. This way you don't have to worry about the problems that arise from certificates. – Josh Sep 19 '08 at 03:48
0

I needed to select an iframe within a popup window and fill out a form. I had trouble using the selectWindow cmd where selenium couldn't find my iframe, so I removed the command.

This selenese worked well for me (where the iframe title and id = account_frame) :

<tr>
  <td>click</td>
  <td>//a[@class='item_add']</td>
  <td></td>
</tr>
<tr>
  <td>windowFocus</td>
  <td>account_frame</td>
  <td></td>
</tr>
<tr>
  <td>waitForPopUp</td>
  <td>account_frame</td>
  <td>10000</td>
</tr>
nicholasklick
  • 1,212
  • 10
  • 14
0

I just trialled adding another selenium function, windowFocus():

// force new window to open at this point - so we can select it later
selenium().getEval("this.browserbot.getCurrentWindow().open('', 'enquiryPopup')");
selenium().click("//input[@value='Submit']");
selenium().windowFocus("enquiryPopup");
selenium().waitForPopUp("enquiryPopup", getWaitTime());
selenium().selectWindow("enquiryPopup");

The test succeeded when I ran it locally, but only with all those method calls - create/focus/wait/select.

I'm about to let the build server run all the tests, and if that succeeds too, I'll be making a library function out of it...!

brasskazoo
  • 76,030
  • 23
  • 64
  • 76
  • For the moment, it has been working, so I'm going to extend it across all tests using popups (we are eventually moving to lightboxes). – brasskazoo Oct 09 '08 at 04:01
-1

Try adding some wait statements around the calls that are causing you issues.

I've had the same errors before and the only way I was able to reliably resolve them was by making calls to System.Threading.Thread.Sleep(5000)..

Peter Bernier
  • 8,038
  • 6
  • 38
  • 53