Actually i have a similar problem and after some search at forums at selenium user groups decide that the Ajax call cause this, AJAX page loading is taking some time but Selenium
is trying to go to next command without waiting the previous call to
complete. selenium.waitForPageToLoad(10000)
does not wait for AJAX, first i try some
speed bumper between the commands, after your Ajax call and just
before you check the text. But after read this blog post about selenium tests http://zurmo.org/wiki/selenium i decide to add selenium.waitForCondition() method to wait for jQuery load. I use this structure now:
selenium.waitForPageToLoad(10000);
selenium.waitForCondition("typeof selenium.browserbot.getCurrentWindow().jQuery == 'function'", "10000");
Thread.sleep(1000L);
Assert.assertTrue("Warning Message", selenium.isTextPresent("elementText"));
Blog post suggest
- Write all your tests in the FireFox IDE and focus first on getting it running successfully there.
- Do not worry about Chrome/IE, as the first objective is a stable test suite in FireFox. It is more important to have it fully stable on one browser than sort-of working in 3 browsers
- Write all your tests to work on FAST speed. In the beginning we thought that because selenium was finicky we had to write everything to run on SLOW speed. This in fact creates problems, so make your test run on FAST speed. We have found only one spot so far that requires temporarily slowing the speed down for several lines. I will mention that in a bit.
Anytime you are doing an action that causes the entire page to load you need to follow the following pattern:
Pattern for going directly to a url
But i strongly recommend to read the blog post.