tags:

views:

1751

answers:

4

hi,

sometimes my selenium tests get timeouts these suggestions: http://stackoverflow.com/questions/88269/how-do-you-get-selenium-to-recognize-that-a-page-loaded did not fix my problem. It mostly happens at the beginning of the test when i use open or openAndWait. The odd thing is the page actually gets opend but the test just stops and does not execute fruther. I use the beta-2 version and multiwindow true. I call my browsers with the custom command. I'm open for any suggestions.

thx

kuku

+1  A: 

Have you tried putting a fixed pause (several seconds) after openAndWait? From my experience all "opens" and "clicks" in selenium (even *AndWait ones) do not guarantee you that the page is fully loaded in the browser before the next selenium command is processed. That's why I always add a small pause after such commands.

Even if you see the page being rendered in the browser, this doesn't necessarily mean everything is available to the Selenium's command processor at that moment.

Igor Brejc
i've added a pause but still it failed sometimes. i had deleteAllCookies as first command and after open, and it stucked at open what i tried next was removing the deleteAllCookies command + keeping your suggestion seems to made my tests more stable thanks.
kukudas
You can also try to set the Selenium speed setting to slow down Selenium as a whole. Experiment with this until your tests become stable.
Igor Brejc
yeah i tried that too it's really frustrating sometimes it works 6-7 times and then it fails :( but the pause command made it run more often stable.
kukudas
A: 

I have the same problem and tried to fix it with addding pause commands before and after the open command, but it didn't work. The open command still timed out. It seems it doesn't detect that a site has loaded. I also tried to increase the timeout span with setTimeout to 30000 but no changes.

A: 

I am new to selenium and I have the same issue, looks like Selenium Server doesn't know that page has already loaded. Have you figured this out...?

A: 

This works for me in IE6, IE7, IE8, FF, Chrome:

<tr>
  <td>waitForCondition</td>
  <td>
    (selenium.browserbot.getCurrentWindow().$$("body").length == 1) ? true : false;
  </td>
  <td>10000</td>
</tr>

It just polls the target window and checks for the body element. It is still susceptible to a timeout, however, but you can set that to whatever you like.

Note: the above code uses Prototype JS to get the body element. This is not required but will need some modifications if you are using another JS lib.

rehanift