|
[HtmlUnit] [ htmlunit-Bugs-1088353 ] JavaScript: Link clicking does not wor: msg#00007java.htmlunit.devel
Bugs item #1088353, was opened at 2004-12-20 13:28 Message generated for change (Settings changed) made by mguillem You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1088353&group_id=47038 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: 1.7 >Status: Closed Resolution: Fixed Priority: 5 Submitted By: Kurt Huwig (kurti) Assigned to: Marc Guillemot (mguillem) Summary: JavaScript: Link clicking does not work correctly Initial Comment: I am using v1.3. If I click on 'ansehen' within this document, using ((HtmlAnchor) page.getAnchors().get(4)).click() which is HtmlAnchor[<a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1:0:_id12';document.forms['_id0']['loadMeasureId'].value='23584776'; document.forms['_id0'].submit(); return false;">] then HtmlUnit does this: GET /monitor/ HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98) Host: localhost:8080 which does not work, while Firefox does: POST /monitor/measures/ListMeasures.jsf HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de-DE; rv:1.7.5) Gecko/20041108 Firefox/1.0 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://localhost:8080/monitor/OperatorMenu.jsf Cookie: JSESSIONID=2C853F8C2D93A828856E1B3E3959F69C Content-Type: application/x-www-form-urlencoded Content-Length: 69 _id0=_id0&_id0%3A_idcl=_id0%3A_id1%3A0%3A_id12&loadMeasureId=23584776 which works fine. This is the HTML-document, created by JavaServerFaces: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>SPONTS/Monitor - Überwachungsmaßnahmen</title> <link rel="stylesheet" type="text/css" href="/monitor/styles.css"/> </head> <body> <div style="width: 100%; background-color: #000080"> <div style="width: 100px; height: 65px; float: left; text-align: center"> <a href="http://www.iku-ag.de" target="_blank"><img src="/pics/iKu-Logo.gif" width="80" height="65" alt="iKu Systemhaus AG" name="" border="0" /></a> </div> <div style="height: 55px; padding-top: 10px; text-align: center"> <img src="/pics/sponts.gif" width="297" height="29" alt="SPONTS" name=""><br/> <img src="/pics/smtpproxy.gif" width="117" height="12" alt="SMTP PROXY"> </div> </div> <div style="width: 10em; float: left; margin: auto; background-color: #e0e0e0"> <p> <a href="/monitor/measures/CreateMeasure.jsf">Maßnahme anlegen</a> </p> <p> <a href="/monitor/OperatorMenu.jsf">Maßnahme suchen</a> </p> <p> <a href="/monitor/Logout.jsf">Abmelden</a> </p> </div> <form id="_id0" method="post" action="/monitor/measures/ListMeasures.jsf" enctype="application/x-www-form-urlencoded"> <table class="table"> <thead> <tr> <th class="tableheader" scope="col">Zu überw. Kennung</th> <th class="tableheader" scope="col">Mailbox</th> <th class="tableheader" scope="col">Zuordnungsnummer</th> <th class="tableheader" scope="col"></th> <th class="tableheader" scope="col"></th> </tr> </thead> <tbody> <tr class="odd"> <td>monitor1@xxxxxxxxx</td> <td>monitor1</td> <td>monitorref</td> <td><a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1:0:_id12';document.forms['_id0']['loadMeasureId'].value='23584776'; document.forms['_id0'].submit(); return false;">ansehen</a></td> <td><a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1:0:_id16';document.forms['_id0']['loadMeasureId'].value='23584776'; document.forms['_id0'].submit(); return false;">löschen</a></td> </tr> </tbody> </table> <input type="hidden" name="_id0" value="_id0" /><input type="hidden" name="_id0:_idcl" /><input type="hidden" name="loadMeasureId" /></form> </p> </div> </body> </html> ---------------------------------------------------------------------- >Comment By: Marc Guillemot (mguillem) Date: 2006-03-01 16:09 Message: Logged In: YES user_id=402164 Closing as this has been fixed since a long time. Please open a new issue with details, if you have an other problem to report. ---------------------------------------------------------------------- Comment By: Marc Guillemot (mguillem) Date: 2006-01-14 15:03 Message: Logged In: YES user_id=402164 and perhaps open a new issue for a new problem ---------------------------------------------------------------------- Comment By: Brad Clarke (yourgod) Date: 2006-01-13 20:52 Message: Logged In: YES user_id=257129 What does not work? This is all very hard to read, maybe you should use attachments intead of copy/paste. ---------------------------------------------------------------------- Comment By: Kurt Huwig (kurti) Date: 2006-01-13 17:45 Message: Logged In: YES user_id=78306 Upp, forgot to say what's up: It does not work with 1.7 ---------------------------------------------------------------------- Comment By: Kurt Huwig (kurti) Date: 2006-01-13 17:17 Message: Logged In: YES user_id=78306 1) testClearLog(test.t01.T0174_a)======= EXCEPTION START ======== EcmaError: lineNumber=[4] column=[0] lineSource=[ f.elements['_id0:_link_hidden_'].value='';] name=[TypeError] sourceName=[Embedded script] message=[TypeError: Cannot set property "value" of undefined to "" (Embedded script#4)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot set property "value" of undefined to "" (Embedded script#4) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:253) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:721) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:209) at com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(HtmlScript.java:168) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.handleCharacters(HTMLParser.java:426) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:387) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249) at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367) at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015) at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888) at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831) at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:330) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:245) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:116) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:84) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:671) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:338) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:364) at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:217) at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:124) Enclosed exception: org.mozilla.javascript.EcmaError: TypeError: Cannot set property "value" of undefined to "" (Embedded script#4) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3240) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3230) at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3246) at org.mozilla.javascript.ScriptRuntime.typeError3(ScriptRuntime.java:3272) at org.mozilla.javascript.ScriptRuntime.undefWriteError(ScriptRuntime.java:3294) at org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1418) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2753) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:149) at org.mozilla.javascript.Context.evaluateString(Context.java:1220) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:249) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:721) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:209) at com.gargoylesoftware.htmlunit.html.HtmlScript.appendChild(HtmlScript.java:168) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.handleCharacters(HTMLParser.java:426) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:387) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249) == CALLING JAVASCRIPT == function clear__5Fid0() { var f = document.forms['_id0']; f.elements['_id0:_link_hidden_'].value=''; f.target=''; } clear__5Fid0(); // ======= EXCEPTION END ======== ---------------------------------------------------------------------- Comment By: Brad Clarke (yourgod) Date: 2005-02-25 20:43 Message: Logged In: YES user_id=257129 You example works fine for me with latest CVS code. Please use that instead of 1.4 until another release is made. ---------------------------------------------------------------------- Comment By: Kurt Huwig (kurti) Date: 2005-02-13 13:44 Message: Logged In: YES user_id=78306 I have another example failing with 1.4. Unfortunately I did now understand how to write a HtmlUnit test the way you did it. <form id="_id0" method="post" action="action" enctype="application/x-www-form-urlencoded"> <a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1'; document.forms['_id0'].submit(); return false;">Link</a> <input type="hidden" name="_id0" value="_id0" /> <input type="hidden" name="_id0:_idcl" /> </form> A click on the link gives: EcmaError: lineNumber=[1] column=[0] lineSource=[function () {] name=[TypeError] sourceName=[event for HtmlAnchor[<a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1'; document.forms['_id0'].submit(); return false;">]] message=[TypeError: Cannot set property "value" of undefined to "_id0:_id1" (event for HtmlAnchor[<a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1'; document.forms['_id0'].submit(); return false;">]#1)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot set property "value" of undefined to "_id0:_id1" (event for HtmlAnchor[<a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1'; document.forms['_id0'].submit(); return false;">]#1) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:341) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:749) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:107) at test.t01.T0174_a.testClearLog(T0174_a.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at de.ikuag.iku.test.aegis.JUnitTest.start(Unknown Source) at test.t01.T0174_a.main(T0174_a.java:119) Enclosed exception: org.mozilla.javascript.EcmaError: TypeError: Cannot set property "value" of undefined to "_id0:_id1" (event for HtmlAnchor[<a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1'; document.forms['_id0'].submit(); return false;">]#1) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3240) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3230) at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3246) at org.mozilla.javascript.ScriptRuntime.typeError3(ScriptRuntime.java:3272) at org.mozilla.javascript.ScriptRuntime.undefWriteError(ScriptRuntime.java:3294) at org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1418) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2753) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140) at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:88) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:336) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:749) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:107) at test.t01.T0174_a.testClearLog(T0174_a.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at de.ikuag.iku.test.aegis.JUnitTest.start(Unknown Source) at test.t01.T0174_a.main(T0174_a.java:119) == CALLING JAVASCRIPT == function () { [native code, arity=0] } ---------------------------------------------------------------------- Comment By: Marc Guillemot (mguillem) Date: 2004-12-23 18:23 Message: Logged In: YES user_id=402164 The common-lang dependency has been added yesterday in the maven config file. The ant script is only a backup solution and wasn't updated. This is now done. ---------------------------------------------------------------------- Comment By: Kurt Huwig (kurti) Date: 2004-12-23 17:34 Message: Logged In: YES user_id=78306 Thank you, it works now. Something different: the commons-lang.jar was missing even after 'ant initialize'. I had to download it myself to get things compiling. ---------------------------------------------------------------------- Comment By: Marc Guillemot (mguillem) Date: 2004-12-21 12:19 Message: Logged In: YES user_id=402164 I've reduced your html code to find cause of the problem: document.forms['xxx'] was only working with "xxx" the name of a form and not the id. This is now fixed in cvs. If you have other bugs to submit, please try to reduce it to the smallest amount of code producing the error. And best: in the form of a unit test like the ones htmlunit uses. ---------------------------------------------------------------------- Comment By: Kurt Huwig (kurti) Date: 2004-12-21 11:32 Message: Logged In: YES user_id=78306 /me stupid Here is the HTML code: ------------ HTML ----------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head></head> <body> <form id="_id0" method="post" action="http://www.google.com/" enctype="application/x-www-form-urlencoded"> <a href="#" onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id1:0:_id12';document.forms['_id0']['loadMeasureId'].value='23584776'; document.forms['_id0'].submit(); return false;">click me</a> <input type="hidden" name="_id0" value="_id0" /><input type="hidden" name="_id0:_idcl" /><input type="hidden" name="loadMeasureId" /> </form> </body> </html> ------------ HTML ----------- ---------------------------------------------------------------------- Comment By: Marc Guillemot (mguillem) Date: 2004-12-21 11:23 Message: Logged In: YES user_id=402164 I think that you have copied your java code in place of the html. ---------------------------------------------------------------------- Comment By: Kurt Huwig (kurti) Date: 2004-12-20 16:41 Message: Logged In: YES user_id=78306 Unfortunaltely, I don't have the time for further tests. But I was able to trigger an exception: ------------ Java ---------------- import java.net.*; import com.gargoylesoftware.htmlunit.*; import com.gargoylesoftware.htmlunit.html.*; public class JavaScriptTest { public static void main(String[] arguments) { try { new JavaScriptTest().test(); } catch (Exception e) { e.printStackTrace(); } } private void test() throws Exception { final WebClient webClient = new WebClient(); HtmlPage page = (HtmlPage) webClient.getPage( new URL("http://localhost/~kurt/test.html")); System.out.println(page.getWebResponse().getContentAsString()); page = (HtmlPage) ((HtmlAnchor) page.getAnchors().get(0)).click(); System.out.println(page.getWebResponse().getContentAsString()); } } ------------ Java ---------------- ------------ HTML --------------- import java.net.*; import com.gargoylesoftware.htmlunit.*; import com.gargoylesoftware.htmlunit.html.*; public class JavaScriptTest { public static void main(String[] arguments) { try { new JavaScriptTest().test(); } catch (Exception e) { e.printStackTrace(); } } private void test() throws Exception { final WebClient webClient = new WebClient(); HtmlPage page = (HtmlPage) webClient.getPage( new URL("http://localhost/~kurt/test.html")); System.out.println(page.getWebResponse().getContentAsString()); page = (HtmlPage) ((HtmlAnchor) page.getAnchors().get(0)).click(); System.out.println(page.getWebResponse().getContentAsString()); } } ------------ HTML --------------- ======= EXCEPTION START ======== Exception class=[org.mozilla.javascript.EvaluatorException] com.gargoylesoftware.htmlunit.ScriptException: The undefined value has no properties. at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:280) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:710) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:102) at JavaScriptTest.test(JavaScriptTest.java:34) at JavaScriptTest.main(JavaScriptTest.java:22) Enclosed exception: org.mozilla.javascript.EvaluatorException: The undefined value has no properties. at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:114) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:591) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:630) at org.mozilla.javascript.Context.reportRuntimeError0(Context.java:600) at org.mozilla.javascript.Undefined.reportError(Undefined.java:138) at org.mozilla.javascript.Undefined.get(Undefined.java:60) at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1396) at org.mozilla.javascript.ScriptRuntime.getStrIdElem(ScriptRuntime.java:983) at org.mozilla.javascript.ScriptRuntime.getElem(ScriptRuntime.java:956) at org.mozilla.javascript.Interpreter.do_getElem(Interpreter.java:2770) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2050) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2163) at org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:62) at org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:55) at org.mozilla.javascript.Context.evaluateReader(Context.java:820) at org.mozilla.javascript.Context.evaluateString(Context.java:784) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:272) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:710) at com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:102) at JavaScriptTest.test(JavaScriptTest.java:34) at JavaScriptTest.main(JavaScriptTest.java:22) == CALLING JAVASCRIPT == GargoyleWrapper0() ======= EXCEPTION END ======== ---------------------------------------------------------------------- Comment By: Marc Guillemot (mguillem) Date: 2004-12-20 14:57 Message: Logged In: YES user_id=402164 - have you tested it again the latest CVS version? - if you're able to provide a really simpler test illustrating the problem, it will be easier for developers to understand the problem without having to face your custom logic. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1088353&group_id=47038 ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [HtmlUnit] [ htmlunit-Feature Requests-1168346 ] add support to event for IE ctrlKey & shiftKey properties, SourceForge.net |
|---|---|
| Next by Date: | [HtmlUnit] CVS Commit: HttpWebConnectionTest.java: fixed javadoc warning, yourgod |
| Previous by Thread: | [HtmlUnit] [ htmlunit-Feature Requests-1168346 ] add support to event for IE ctrlKey & shiftKey properties, SourceForge.net |
| Next by Thread: | [HtmlUnit] CVS Commit: HttpWebConnectionTest.java: fixed javadoc warning, yourgod |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |