4

sometimes my selenium tests get timeouts these suggestions: 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

Community
  • 1
  • 1
kukudas
  • 4,834
  • 5
  • 44
  • 65

3 Answers3

1

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
  • 169
  • 1
  • 1
  • 9
1

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
  • 18,714
  • 13
  • 76
  • 95
  • 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 Apr 03 '09 at 10:46
  • 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 Apr 03 '09 at 11:19
  • 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 Apr 03 '09 at 15:10
1

I had a similar problem, mine will just timeout no matter what.
I see the page is rendered completely but for some reason selenium.open(relative_url) will just timeout.

I tried setting timeout to like 120 seconds and still the same issue. Setting the speed to really slow didn't help either.

I fixed it by handling the exception with a try/catch and basically proceed with validation if the page really rendered or not (works like a charm) so my code looks like this:

try {
    selenium.open(relative_url);
} catch (Exception e) {
    // check if page rendered completely here
}
// continue
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
JGE
  • 11
  • 1