[Webtest] repost: webtest and javascript issues

Bill Milbratz webtest@lists.canoo.com
Mon, 19 May 2003 13:30:20 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------=_NextPartTM-000-cad15ddc-772e-4ba9-88a2-652b78027146
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C31E34.B3EEF320"

------_=_NextPart_001_01C31E34.B3EEF320
Content-Type: text/plain;
	charset="iso-8859-1"

hi,

I posted a few days ago about a javascript issue I encountered using
webtest. I'm following up with more  generic question about javascript
versions, httpunit versions and successful webtesting javascript-heavy
pages.

In the latest problem, httpunit's javascript engine is dying on a javascript
function:
   TypeError: getElementsByTagName is not a function. (httpunit; line 13)

Looking at the httpunit.jar's manifest from my webtest download, I see it's
"HttpUnit-Version: 1.5.2"

>From the httpunit site, I see that 1.5.3 supports this function:
  "getElementsByName - returns an array of all elements in the document with
the specified name"
  http://httpunit.sourceforge.net/doc/javascript-support.html

Can I simply swap out the HttpUnit.jar with the new version? What about the
HttpUnitWithJTidy (both contain the HttpUnit javascript engine class) ?

Does anyone have any 'best practices' for dealing with javascript issues and
webtest? The HttpUnit site indicates that it supports javascript 1.1. Our
designers have been using javascript 1.5. How does one deal with this
version-discrepancy?:

   "JavaScript support is very basic at present. The near-term goal is full
JavaScript 1.1 support.    Currently, we do not plan to support
browser-specific JavaScript. Please let us know via the mailing list your
priorities for missing features"

thanks,

bill m

postscript:

I replaced httpunit.jar and httpunitWithJTidy.jar with version 1.5.3 of
httpunit.jar ). I got the same error. After adding a check for
document.getElementsByTagName, javascript choked on 'item(i)' reference. I
got past the problem by adding additional check for
document.getElementsByTagName.item.

Check1>> if (! document.getElementsByTagName)
       {
         return;
       }
       var allDetails = document.getElementsByTagName("tbody");
Check2>    if (!allDetails.item)
       {
          return;
       }
       for (i=0; i<len; i++)
       {
          itemID = allDetails.item(i).id;
          ...........
       }



------_=_NextPart_001_01C31E34.B3EEF320
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>repost: webtest and javascript issues</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>hi,</FONT>
</P>

<P><FONT SIZE=3D2>I posted a few days ago about a javascript issue I =
encountered using webtest. I'm following up with more&nbsp; generic =
question about javascript versions, httpunit versions and successful =
webtesting javascript-heavy pages.</FONT></P>

<P><FONT SIZE=3D2>In the latest problem, httpunit's javascript engine =
is dying on a javascript function:</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp; TypeError: getElementsByTagName is not =
a function. (httpunit; line 13)</FONT>
</P>

<P><FONT SIZE=3D2>Looking at the httpunit.jar's manifest from my =
webtest download, I see it's&nbsp; &quot;HttpUnit-Version: =
1.5.2&quot;</FONT>
</P>

<P><FONT SIZE=3D2>From the httpunit site, I see that 1.5.3 supports =
this function:</FONT>
<BR><FONT SIZE=3D2>&nbsp; &quot;getElementsByName - returns an array of =
all elements in the document with the specified name&quot;</FONT>
<BR><FONT SIZE=3D2>&nbsp; <A =
HREF=3D"http://httpunit.sourceforge.net/doc/javascript-support.html" =
TARGET=3D"_blank">http://httpunit.sourceforge.net/doc/javascript-support=
.html</A></FONT>
</P>

<P><FONT SIZE=3D2>Can I simply swap out the HttpUnit.jar with the new =
version? What about the HttpUnitWithJTidy (both contain the HttpUnit =
javascript engine class) ?</FONT></P>

<P><FONT SIZE=3D2>Does anyone have any 'best practices' for dealing =
with javascript issues and webtest? The HttpUnit site indicates that it =
supports javascript 1.1. Our designers have been using javascript 1.5. =
How does one deal with this version-discrepancy?:</FONT></P>

<P><FONT SIZE=3D2>&nbsp;&nbsp; &quot;JavaScript support is very basic =
at present. The near-term goal is full JavaScript 1.1 =
support.&nbsp;&nbsp;&nbsp; Currently, we do not plan to support =
browser-specific JavaScript. Please let us know via the mailing list =
your priorities for missing features&quot;</FONT></P>

<P><FONT SIZE=3D2>thanks,</FONT>
</P>

<P><FONT SIZE=3D2>bill m</FONT>
</P>

<P><FONT SIZE=3D2>postscript:</FONT>
</P>

<P><FONT SIZE=3D2>I replaced httpunit.jar and httpunitWithJTidy.jar =
with version 1.5.3 of httpunit.jar ). I got the same error. After =
adding a check for document.getElementsByTagName, javascript choked on =
'item(i)' reference. I got past the problem by adding additional check =
for document.getElementsByTagName.item.</FONT></P>

<P><FONT SIZE=3D2>Check1&gt;&gt; if (! =
document.getElementsByTagName)</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
return;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var allDetails =
=3D document.getElementsByTagName(&quot;tbody&quot;);</FONT>
<BR><FONT SIZE=3D2>Check2&gt;&nbsp;&nbsp;&nbsp; if =
(!allDetails.item)</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
return;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (i=3D0; =
i&lt;len; i++)</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itemID =
=3D allDetails.item(i).id;</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
...........</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
</P>
<BR>

</BODY>
</HTML>
------_=_NextPart_001_01C31E34.B3EEF320--

------=_NextPartTM-000-cad15ddc-772e-4ba9-88a2-652b78027146--