8 Replies Last post: Nov 18, 2008 2:30 AM by Larry Jacobson  
Beginner 8 posts since
Apr 29, 2008
Currently Being Moderated

Jun 5, 2008 1:06 AM

ERROR: Couldn't access document.body.  Is this HTML page fully loaded? how do i handle this exception?

Hi,

 

I am using selenium RC to automate my test. Everything is working fine but i am facing problems due to the below Selenium Exception:

"ERROR: Couldn't access document.body.  Is this HTML page fully loaded?"

I am scripting using 'Ruby' and this exception  my recue block is executed while searching for any element / text on the page. I have also made use of the assertions still this error occurs, dont know why, i am performing action on the element only after the is_element_present returns true but this error occurs while i am waiting for the element to be present.

 

Please help.

Thanks,

Pooja

this Advanced 68 posts since
May 9, 2008

post the section of code that throws this exception.

Ankush Beginner 1 posts since
Jun 26, 2008

Hi,

 

I found the similar issue with same error message as

"Selenium.SeleniumException : ERROR: Couldn't access document.body. Is this HTML page fully loaded?"

 

This error is not shown everytime for a single test suite execution. Instead it appears for different suites, and on running the failed suites again, these are passed with error shown for some other suites.

 

The details of the environment used is as:
OS: Win XP (Pro) Service Pack #2
Web Application under test developed in .net.

For Selenium Automation Testbed we are using following:
MS Visual Studio Express Edition C# 2005/2008.
NUnit 2.4.6
selenium-remote-control-1.0-beta-1

 

The error details are as:

 

==========================================Error Start=======================================

Selenium.SeleniumException : ERROR: Couldn't access document.body. Is this HTML page fully loaded?

 

----------------------------------------------------------------------------------------------------------------------------------------------------------

at Selenium.HttpCommandProcessor.DoCommand(String command, String[] args) in C:\Vault\QualityAssurance\Selenium\EMG.ITM.CompleteWorkflow\Core\HttpCommandProcessor.cs:line 95
at Selenium.HttpCommandProcessor.GetString(String commandName, String[] args) in C:\Vault\QualityAssurance\Selenium\EMG.ITM.CompleteWorkflow\Core\HttpCommandProcessor.cs:line 164
at Selenium.HttpCommandProcessor.GetBoolean(String commandName, String[] args) in C:\Vault\QualityAssurance\Selenium\EMG.ITM.CompleteWorkflow\Core\HttpCommandProcessor.cs:line 249
at Selenium.DefaultSelenium.IsTextPresent(String pattern) in C:\Vault\QualityAssurance\Selenium\EMG.ITM.CompleteWorkflow\Core\DefaultSelenium.cs:line 948
at Utilities.WaitTillPageLoad(ISelenium selenium, String TextPresent, Int32 Time) in C:\Vault\QualityAssurance\Selenium\EMG.ITM.CompleteWorkflow\EMG.ITM.Selenium_WorkflowSuite\Utilities\Utility.cs:line 37
at Utilities.LoginTraffiq(ISelenium selenium, String UserName, String PassWord) in C:\Vault\QualityAssurance\Selenium\EMG.ITM.CompleteWorkflow\EMG.ITM.Selenium_WorkflowSuite\Utilities\Utility.cs:line 84
at EMG.ITM.CompleteWorkflow.cLogin.AgencyBuyer() in C:\Vault\QualityAssurance\Selenium\EMG.ITM.CompleteWorkflow\EMG.ITM.Selenium_WorkflowSuite\03LoginToTraffIQ.cs:line 55
==========================================Error End=======================================

 

 

 

Thanks

Ankush

Jean-Charles Meyrignac Beginner 148 posts since
Oct 12, 2006

I added some comments on bug SRC-302:

 

http://jira.openqa.org/browse/SRC-302

Thibaut Pro 91 posts since
Oct 28, 2008

Are you testing an AJAX based web application ?

 

If yes, you have to wait until a certain element is present in your page using the Wait object (see the javadoc of Selenium, or the equivalent if you are not using java). You have to choose an element in your DOM tree that you are sure that if present the entire page is loaded.

 

You can also reduce the speed of selenium by using the Selenium.setSpeed method. It may help.

 

BRs

Jean-Charles Meyrignac Beginner 148 posts since
Oct 12, 2006

No, there is no Ajax in this part, but we have a submit in a hidden frame.

 

I have a particular test that fails once every 3 or 4 times I run it.

It's very weird.

I have tons of waitFor everywhere, but it still fails.

 

About setSpeed, I'd like to avoid using it or using pause, because it's like hiding the problem under the carpet...

Andrew McGregor Beginner 2 posts since
Nov 7, 2008

What worked for me was to change:

 

click(...)

waitForPopUp (summaryWindow)

assertTextPresent (abc)

 

to

 

click(...)

waitForPopUp (summaryWindow)

waitForTextPresent (abc)

assertTextPresent (abc)

Jean-Charles Meyrignac Beginner 148 posts since
Oct 12, 2006

No, this does not work here.

 

I have a similar function as your waitForPopup, but it still bugs.

I added captureEntirePageScreenshot on every instruction of my test, and one out of 20 times, the screenshot is blank, meaning that the page is not loaded.

 

Still investigating the problem...

Larry Jacobson Beginner 1 posts since
Nov 18, 2008

I'm experiencing the same problem with 0.9.2 and 1.0-beta-1.   Has anyone figured out a workaround yet?

More Like This

  • Retrieving data ...