AW: [Webtest] Help needed: Encoding Bug in Webtest/underlying library?

Peter Hoepfl Peter Hoepfl" <Hoepfl@atrada.net
Wed, 20 Aug 2008 15:58:48 +0200


Hi Marc,

wow, thank you for the fast response (you seem to know the reason =
already...)
The issue is opened under ID 2062406.

Thanks again, you're doing a great job!

Bye,

Peter

> -----Urspr=FCngliche Nachricht-----
> Von: webtest-admin@lists.canoo.com [mailto:webtest-
> admin@lists.canoo.com] Im Auftrag von Marc Guillemot
> Gesendet: Mittwoch, 20. August 2008 15:44
> An: webtest@lists.canoo.com
> Betreff: Re: [Webtest] Help needed: Encoding Bug in Webtest/underlying
> library?
>=20
> Ok, I understand now.
>=20
> This is an issue in the getter on the script object for innerHTML that
> doesn't escape quotes.
>=20
> Can you open an issue by HtmlUnit for that?
>=20
> Cheers,
> Marc.
> --
> Blog: http://mguillem.wordpress.com
>=20
>=20
> Peter Hoepfl wrote:
> > Hi Marc,
> >
> > I just managed to narrow down the problem:
> > It has something to do with how a clickelement-step is used in a
> test.
> > I try to explain it:
> > When you use clickElement with an xpath attribute (see example
> below),
> > the internal StoreElementAttribute.findElement method returns the
> (xml or html) decoded version of the HtmlElement. (And that is WRONG!)
> > I wrote my own clickelement step where I simply dump the HtmlElement
> with toString.
> > If I use clickElement with htmlid instead, the HtmlElement contains
> the correct (not) decoded version.
> >
> > Our real world scenario is this - I hope I can explain that with a
> few sentences:
> > We try to click a link that has an onclick attribute. The onclick
> attribute contains a functioncall with &quot; for the double quotes of
> the function parameters.
> > The htmlcode for link itself is not in the page when the page is
> delivered but inserted afterwards via an async call. The insert =
happens
> by setting the innerHTML of a div in the original page.
> >
> > If you save my sample html code to a file and use firefox to inspect
> the code you will see that everything is ok.
> > But with webtest (I used build 1705 an 1714) you will get a java
> script error saying that this is invalid javascript code:
> > This is the webtest error from our project:
> > JavaScript error loading page
> http://localhost:8081/backend/page/list.htm: syntax error (onclick
> event for HtmlAnchor[<a href=3D"#" onclick=3D"var ret; =
ret=3Dfuncxy(this,"
> editpage=3D"">]#2)
> > Instead of the quote (") there should be &quot; in the string after
> funcxy(this, !
> >
> > I think this a bug in webtest itself- what do you mean?
> >
> >
> > Best regards,
> >
> > Peter
> >
> >> -----Urspr=FCngliche Nachricht-----
> >> Von: webtest-admin@lists.canoo.com [mailto:webtest-
> >> admin@lists.canoo.com] Im Auftrag von Marc Guillemot
> >> Gesendet: Mittwoch, 20. August 2008 14:26
> >> An: webtest@lists.canoo.com
> >> Betreff: Re: [Webtest] Help needed: Encoding Bug in
> Webtest/underlying
> >> library?
> >>
> >> Hi Peter,
> >>
> >> the list is correct.
> >>
> >> Can you precise what your real problem is?
> >>
> >> Indeed it seems to me that the problem you report concerns how the
> >> current page state is dumped to a file. This looks like an error
> (you
> >> can report an issue by HtmlUnit for that) but this has no impact on
> the
> >> script execution.
> >>
> >> Cheers,
> >> Marc.
> >> --
> >> Blog: http://mguillem.wordpress.com
> >>
> >>
> >> Peter Hoepfl wrote:
> >>> Hello,
> >>>
> >>> this is my first post to this list, I hope I'm doing this correct.
> >>>
> >>> We have a problem with &quot; getting decoded twice in certain
> >> javascript code when invoked from Webtest.
> >>> I managed to write a simple testcode that shows my problem, here =
is
> >> my testcode:
> >>> <html>
> >>> <body>
> >>> <a href=3D"#" title=3D"mytest"
> >>
> =
onclick=3D"javascript:document.getElementById(&quot;test&quot;).innerHTML=

> >> =3D document.getElementById(&quot;async&quot;).innerHTML;">do
> >> something</a>
> >>> <div id=3D"test">
> >>> huh
> >>> </div>
> >>> <div id=3D"async">
> >>> <a href=3D"#" title=3D"test2"
> >>
> =
onclick=3D"javascript:document.getElementById(&quot;testoutput&quot;).inn=

> >> erHTML =3D &quot;hello&quot;">do something more</a>
> >>> </div>
> >>> <div id=3D"testoutput">
> >>> </div>
> >>> </body>
> >>> </html>
> >>>
> >>> When I run this webtest :
> >>> 			<invoke url=3D"/test.htm"/>
> >>> 			<clickElement xpath=3D"//a[@title=3D'mytest']"/>
> >>>
> >>> The resulting page looks like this:
> >>> <html>
> >>>   <head/>
> >>>   <body>
> >>>     <a href=3D"#" title=3D"mytest"
> >>
> =
onclick=3D"javascript:document.getElementById(&quot;test&quot;).innerHTML=

> >> =3D document.getElementById(&quot;async&quot;).innerHTML;">
> >>>       do something
> >>>     </a>
> >>>     <div id=3D"test">
> >>>       <a href=3D"#" title=3D"test2"
> >> onclick=3D"javascript:document.getElementById(" testoutput=3D"">
> >>>         do something more
> >>>       </a>
> >>>     </div>
> >>>     <div id=3D"async">
> >>>       <a href=3D"#" title=3D"test2"
> >>
> =
onclick=3D"javascript:document.getElementById(&quot;testoutput&quot;).inn=

> >> erHTML =3D &quot;hello&quot;">
> >>>         do something more
> >>>       </a>
> >>>     </div>
> >>>     <div id=3D"testoutput">
> >>>     </div>
> >>>   </body>
> >>> </html>
> >>>
> >>> As you can see the &quot; gets decoded although it shouldn't
> leading
> >> to a broken javascript code in the test-div.
> >>> When I perform the click in a regular browser the code is correct.
> >>> To check simply save the code above to a file perfom the click in =
a
> >> regular browser.
> >>> Any idea what goes wrong?
> >>>
> >>>
> >>> Best Regards,
> >>>
> >>> Peter H=F6pfl
> >>>
> >>> _______________________________________________
> >>> WebTest mailing list
> >>> WebTest@lists.canoo.com
> >>> http://lists.canoo.com/mailman/listinfo/webtest
> >>>
> >> _______________________________________________
> >> WebTest mailing list
> >> WebTest@lists.canoo.com
> >> http://lists.canoo.com/mailman/listinfo/webtest
> > _______________________________________________
> > WebTest mailing list
> > WebTest@lists.canoo.com
> > http://lists.canoo.com/mailman/listinfo/webtest
> >
>=20
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest