Reputation: 479
Couldn't access document.body. Is this HTML page fully loaded? This is the error I an getting with selenium RC . I am working on testNG framework and I write my test scripts in java in Eclipse.I use Selenium RC to execute my test scripts. This is the error I am getting after click on save button on an Edit window.Though I have used Thread.sleep("1000") between click on save and next call My Piece of code looks like
selenium.click(saveButton);
Thread.sleep(sleep);
while(selenium.isTextPresent("Processing ..."))
Thread.sleep(sleep);
I am getting the error on while(selenium.isTextPresent("Processing ...")) line.
Upvotes: 0
Views: 373
Reputation: 3649
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
Pattern for going directly to a url
open – myURL
waitForPageToLoad
waitForCondition – selenium.browserbot.getCurrentWindow().jQuery.active == 0(I change here to "typeof selenium.browserbot.getCurrentWindow().jQuery == 'function'" this is working for me.)
But i strongly recommend to read the blog post.
Upvotes: 0
Reputation: 548
you can try out different wait statement. waitForTestPresent, WaitForElementPresent. this way selenium know how much to wait for and what to wait for. also u can use clickAndWait..
Upvotes: 0
Reputation: 9570
After your selenium.click(saveButton)
, instead of a Thread.sleep(sleep)
that might not be the right length of time, you should selenium.waitForPageToLoad(...)
.
Upvotes: 1