views:

21344

answers:

6

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

+1  A: 

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
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?
brass-kazoo
*iehta and *chrome allow for https support. This way you don't have to worry about the problems that arise from certificates.
Josh
A: 

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...!

brass-kazoo
Please do let us know whether it worked!
mcherm
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).
brass-kazoo
This is very helpful! I'm able to make my test work. Thanks!
logoin
A: 

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
+2  A: 

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>
mugafuga
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
A: 

I am writing a testcase where I need to click on a report, after click on the button, an alert message "Report Definition has changed, Do you want to check for new fields if any?" pops up.

I have tried many ways to get pass this alert message by using: "waitforalert", "waitforalertpresent", "assertalert", and "assertconfirmation". None of those worked, can you please suggest an alternative way to get pass this alert issue?

Sample code is shown below:

<tr>
    <td>click</td>
    <td>xpath=//button[@id='editlink1']</td>
    <td></td>
</tr>
<tr>
    <td>waitForAlertPresent</td>
    <td></td>
    <td></td>
</tr>
<tr>
    <td>assertAlert</td>
    <td>Report Definition has changed, Do you want to check for new fields if any?</td>
    <td></td>
</tr>

Thanks,

Best,

Hadaes

Hades
You should probably better ask this as a new question, not post it as an answer to some other question. More people would see it that way and would try to answer. The "Ask Question" button is in the top right.
sth
A: 

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