Ok, I understand now. This is an issue in the getter on the script object for innerHTML that doesn't escape quotes.
Can you open an issue by HtmlUnit for that? Cheers, Marc. -- Blog: http://mguillem.wordpress.com 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 " 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="#" onclick="var ret; > ret=funcxy(this," editpage="">]#2) > Instead of the quote (") there should be " in the string after > funcxy(this, ! > > I think this a bug in webtest itself- what do you mean? > > > Best regards, > > Peter > >> -----Ursprüngliche Nachricht----- >> Von: [EMAIL PROTECTED] [mailto:webtest- >> [EMAIL PROTECTED] Im Auftrag von Marc Guillemot >> Gesendet: Mittwoch, 20. August 2008 14:26 >> An: [email protected] >> 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 " 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="#" title="mytest" >> onclick="javascript:document.getElementById("test").innerHTML >> = document.getElementById("async").innerHTML;">do >> something</a> >>> <div id="test"> >>> huh >>> </div> >>> <div id="async"> >>> <a href="#" title="test2" >> onclick="javascript:document.getElementById("testoutput").inn >> erHTML = "hello"">do something more</a> >>> </div> >>> <div id="testoutput"> >>> </div> >>> </body> >>> </html> >>> >>> When I run this webtest : >>> <invoke url="/test.htm"/> >>> <clickElement xpath="//[EMAIL PROTECTED]'mytest']"/> >>> >>> The resulting page looks like this: >>> <html> >>> <head/> >>> <body> >>> <a href="#" title="mytest" >> onclick="javascript:document.getElementById("test").innerHTML >> = document.getElementById("async").innerHTML;"> >>> do something >>> </a> >>> <div id="test"> >>> <a href="#" title="test2" >> onclick="javascript:document.getElementById(" testoutput=""> >>> do something more >>> </a> >>> </div> >>> <div id="async"> >>> <a href="#" title="test2" >> onclick="javascript:document.getElementById("testoutput").inn >> erHTML = "hello""> >>> do something more >>> </a> >>> </div> >>> <div id="testoutput"> >>> </div> >>> </body> >>> </html> >>> >>> As you can see the " 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öpfl >>> >>> _______________________________________________ >>> WebTest mailing list >>> [email protected] >>> http://lists.canoo.com/mailman/listinfo/webtest >>> >> _______________________________________________ >> WebTest mailing list >> [email protected] >> http://lists.canoo.com/mailman/listinfo/webtest > _______________________________________________ > WebTest mailing list > [email protected] > http://lists.canoo.com/mailman/listinfo/webtest > _______________________________________________ WebTest mailing list [email protected] http://lists.canoo.com/mailman/listinfo/webtest

