Skip to main content

Bug Tracker

Side navigation

#4552 closed bug (invalid)

Opened April 17, 2009 06:20AM UTC

Closed November 18, 2010 02:47AM UTC

Last modified March 13, 2012 05:16PM UTC

jQuery error running selenium with 1.3.2 in IE6

Reported by: jaiew Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: support.js, bindReady, selenium, IE6 Cc:
Blocked by: Blocking:

When running selenium for IE6 a javscript error is produced when jQuery-1.3.2 is included into the html page.

Details below:

In revision 6081 of support.js

the following code was added:

87      // Figure out if the W3C box model works as expected
88      // document.body must exist before we can do this
89      jQuery(function(){
90              var div = document.createElement("div");
91     = "1px";
92     = "1px";
94              document.body.appendChild( div );
95              jQuery.boxModel = = div.offsetWidth === 2;
96              document.body.removeChild( div );
97      });

This causes an error as the bindReady function breaks for IE6 in selenium.

When jquery executes the check to see if the document is ready:

// If IE and not an iframe
// continually check to see if the document is ready
if ( document.documentElement.doScroll && window == ) (function(){
	if ( jQuery.isReady ) return;

		try {
			// If IE is used, use the trick by Diego Perini
		} catch( error ) {
			setTimeout( arguments.callee, 0 );

		// and execute any waiting functions

The call to document.documentElement.doScroll("left") doesn't raise an error. This might have something to do with selenium running the page in an iframe, and because there is no error raised, jQuery.ready() is called.

I added the following code on my local copy to the try statement and it now works.

try {
   var div = document.createElement("div");
   document.body.appendChild( div );
   document.body.removeChild( div ).style.display = 'none';

The selenium version information is:

running Selenium RC and Selenium Core 1.0 beta 2, the latest release on the Selenium download page.

However, it also occurred in the latest release before 1.0 which was Selenium RC 0.9.2 and Selenium Core 0.8.3 I believe.

The thing of note is obviously that it's running in Selenium's "single window" mode (the default has changed in the latest version (1.0 beta 2) to be "multi window" mode), where it's injecting the html into the iframe then.

Other possibly secondary things of ntoe:

  • It's using the Java client driver
  • It runs on Selenium Grid (ver 1.0.3)
  • We're using LoggingSelenium which is a wrapper for the actual underlying Selenium libs to log screenshots and stats.

To replicate it was just a simple html page that includes the latest jquery-1.3.2.js and then run selenium in single window mode for IE6 and open the page.

The javascript error that pops up pinpoints this line:

3205 document.body.appendChild( div );

and the error says "document.body is null or not an object"

Attachments (0)
Change History (3)

Changed May 08, 2009 07:17AM UTC by othree comment:1

I have this problem too.

Sometings IE will some this error message.

It occurs frequently on a never visit site(maybe sistes without local cache).

If I use 1.2.6, This error will not show.

So I compare the ready function in this two version.

I found the following code in 1.3.2 might be the problem source.

3061 ensure firing before onload,

3062 maybe late but safe also for iframes

3063 document.attachEvent("onreadystatechange", function(){

3064 if ( document.readyState === "complete" ) {

3065 document.detachEvent( "onreadystatechange", arguments.callee );

3066 jQuery.ready();

3067 }

3068 });

After I remove these lines of code. And the problem is gone.

I think execute this codes after confirm the document is in iframe will solve this problem.

Changed May 08, 2009 07:20AM UTC by othree comment:2

Sorry about the formate.

listing the code again.

3061                 // ensure firing before onload,
3062                 // maybe late but safe also for iframes
3063                 //document.attachEvent("onreadystatechange", function(){
3064                         //if ( document.readyState === "complete" ) {
3065                                 //document.detachEvent( "onreadystatechange", arguments.callee );
3066                                 //jQuery.ready();
3067                         //}
3068                 //});

Changed November 18, 2010 02:47AM UTC by dmethvin comment:3

resolution: → invalid
status: newclosed

I know nothing of Selenium but it appears that people are using it successfully with jQuery: