Menu

#1694 Getting "Cannot call method "getAttribute" of undefined" while executing onload method on IFrame tag

2.10
closed
RBRi
NONE (1)
1
2018-08-07
2015-06-19
No

I am using HtmlUnit 2.10 to automate website that uses ADF javascript but getting exception that prevents further rendering of HtmlPage.

Html page has tag "iframe" shown as below:

<iframe id="user-content-r1:0:pt_region0:0:r1:0:if1::f" title=" " src="/portal/content/crossroads/homepage/Home.html?t=1434706831386" onload="AdfDhtmlInlineFramePeer.__iframeLoadHandler(event)" frameborder="0" allowtransparency="true" style="position:absolute;width:100%;height:100%" tabindex="0"> <br/><br/> <br/> While loading method "AdfDhtmlInlineFramePeer.__iframeLoadHandler(event)" is called.You can get this method in attached javascript(core-11.1.1.7.0-4050.js) at line number: 10175.In this function also i have put some alerts for which i am getting below output through htmlunit 2.10:<br/> <br/> <br/>ALERT: Checking dom window liqckjua7_1 value of b==> AdfIE8Agent Object <br/>ALERT: b.getPlatform name is IE ie page object==> AdfDhtmlPage Object value of <br/>a=[object Event] checking event on window==> [object Event] <br/>ALERT: checking value of HtmlFrameElement==> undefined second checking undefined <br/>ALERT: Just popping to check values before AdfIE8Agent Object and a== [object MouseEvent] <br/>ALERT: getting event target==> null <br/><b>ALERT: Just popping to check values undefined</b> <br/> In above java script i am getting "b" object as undefined alert marked as bold but it should be HtmlInlineFrame Object.Below is the stack trace of exception: <br/> <br/> <br/> 2015-06-19 15:10:34,667 DEBUG [ThreadedRefreshHandler Thread] (HtmlPage.java:1328) - Executing onload handler for HtmlInlineFrame[<iframe id="r1:0:pt_region0:0:r1:0:if1::f" title=" " src="/portal/content/crossroads/homepage/Home.html?t=1434706831386" onload="AdfDhtmlInlineFramePeer.__iframeLoadHandler(event)" frameborder="0" allowtransparency="true" style="position:absolute;width:100%;height:100%" tabindex="0">] 2015-06-19 15:10:34,667 DEBUG [ThreadedRefreshHandler Thread] (EventListenersContainer.java:210) - Executing load handler for HtmlInlineFrame[<iframe id="r1:0:pt_region0:0:r1:0:if1::f" title=" " src="/portal/content/crossroads/homepage/Home.html?t=1434706831386" onload="AdfDhtmlInlineFramePeer.__iframeLoadHandler(event)" frameborder="0" allowtransparency="true" style="position:absolute;width:100%;height:100%" tabindex="0">] 2015-06-19 15:10:34,668 INFO [ThreadedRefreshHandler Thread] (JavaScriptEngine.java:804) - Caught script exception ======= EXCEPTION START ======== EcmaError: lineNumber=[10191] column=[0] lineSource=[null] name=[TypeError] sourceName=[https://mysyniverse.syniverse.com/portal/afr/partition/ie/n/default/opt/core-11.1.1.7.0-4050.js] message=[TypeError: Cannot call method "getAttribute" of undefined (https://mysyniverse.syniverse.com/portal/afr/partition/ie/n/default/opt/core-11.1.1.7.0-4050.js#10191)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call method "getAttribute" of undefined (https://mysyniverse.syniverse.com/portal/afr/partition/ie/n/default/opt/core-11.1.1.7.0-4050.js#10191) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:705) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:637) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:612) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:1001) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:212) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeListeners(EventListenersContainer.java:297) at com.gargoylesoftware.htmlunit.javascript.host.Window.executeEvent(Window.java:2101) at com.gargoylesoftware.htmlunit.javascript.host.Node.executeEvent(Node.java:736) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1338) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:290) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:475) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:342) at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPageIfPossible(BaseFrameElement.java:184) at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPage(BaseFrameElement.java:122) at com.gargoylesoftware.htmlunit.html.BaseFrameElement$2.execute(BaseFrameElement.java:410) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:750) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$500(JavaScriptEngine.java:93) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:700) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:637) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:612) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:1001) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:212) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:232) at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:824) at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:748) at com.gargoylesoftware.htmlunit.html.HtmlElement$1.run(HtmlElement.java:920) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:925) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1298) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:290) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:475) at com.gargoylesoftware.htmlunit.WebClient.loadDownloadedResponses(WebClient.java:2074) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:733) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$500(JavaScriptEngine.java:93) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:700) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:591) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:566) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:975) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:349) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:409) at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute(HtmlScript.java:268) at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:288) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:741) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:701) at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1170) at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1072) at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206) at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:330) at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3126) at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2093) at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:920) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:965) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:247) at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:193) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:156) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:468) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:342) at com.gargoylesoftware.htmlunit.WaitingRefreshHandler.handleRefresh(WaitingRefreshHandler.java:92) at com.gargoylesoftware.htmlunit.ThreadedRefreshHandler$1.run(ThreadedRefreshHandler.java:52) Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot call method "getAttribute" of undefined (https://mysyniverse.syniverse.com/portal/afr/partition/ie/n/default/opt/core-11.1.1.7.0-4050.js#10191) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3629) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3613) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3634) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3650) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3664) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2221) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2215) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1333) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3057) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:103) at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:81) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:630) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:690) ... 70 more Enclosed exception: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot call method "getAttribute" of undefined (https://mysyniverse.syniverse.com/portal/afr/partition/ie/n/default/opt/core-11.1.1.7.0-4050.js#10191) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3629) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3613) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3634) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3650) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3664) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2221) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2215) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1333) at script(https://mysyniverse.syniverse.com/portal/afr/partition/ie/n/default/opt/core-11.1.1.7.0-4050.js:10191) at script.onload(onload event for HtmlInlineFrame[<iframe id="r1:0:pt_region0:0:r1:0:if1::f" title=" " _src="/portal/content/crossroads/homepage/Home.html?t=1434706831386" src="javascript:''" onload="AdfDhtmlInlineFramePeer.__iframeLoadHandler(event)" frameborder="0" allowtransparency="true" style="position:absolute;width:100%;height:100%" tabindex="0">] in https://mysyniverse.syniverse.com/portal/faces/tabnavigation?_afrLoop=12657443321418455&_afrWindowMode=0&_afrWindowId=13y0st4pbd_1#%40%3F_afrWindowId%3D13y0st4pbd_1%26_afrLoop%3D12657443321418455%26_afrWindowMode%3D0%26_adf.ctrl-state%3D13y0st4pbd_85) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3057) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:103) at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:81) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:630) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:690) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:637) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:612) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:1001) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:212) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeListeners(EventListenersContainer.java:297) at com.gargoylesoftware.htmlunit.javascript.host.Window.executeEvent(Window.java:2101) at com.gargoylesoftware.htmlunit.javascript.host.Node.executeEvent(Node.java:736) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1338) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:290) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:475) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:342) at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPageIfPossible(BaseFrameElement.java:184) at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPage(BaseFrameElement.java:122) at com.gargoylesoftware.htmlunit.html.BaseFrameElement$2.execute(BaseFrameElement.java:410) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:750) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$500(JavaScriptEngine.java:93) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:700) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:637) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:612) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:1001) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:212) at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:232) at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:824) at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:748) at com.gargoylesoftware.htmlunit.html.HtmlElement$1.run(HtmlElement.java:920) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:925) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1298) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:290) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:475) at com.gargoylesoftware.htmlunit.WebClient.loadDownloadedResponses(WebClient.java:2074) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:733) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$500(JavaScriptEngine.java:93) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:700) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:591) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:566) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:975) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:349) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:409) at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute(HtmlScript.java:268) at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:288) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:741) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:701) at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1170) at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1072) at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206) at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:330) at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3126) at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2093) at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:920) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:965) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:247) at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:193) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:156) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:468) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:342) at com.gargoylesoftware.htmlunit.WaitingRefreshHandler.handleRefresh(WaitingRefreshHandler.java:92) at com.gargoylesoftware.htmlunit.ThreadedRefreshHandler$1.run(ThreadedRefreshHandler.java:52) == CALLING JAVASCRIPT == function () { [native code, arity=0] } ======= EXCEPTION END ======== <br/> <br/> <b>One more thing i am getting the same exception with HtmlUnit 2.15 API.</b> <br/> <br/> <b> Also curious to know that is HtmlUnit having full support of Oracle ADF framework as few of the responses from the server are coming in the form of XMLs and rendered on UI in the for of Html. But when I use HtmlUnit API to get such pages I am getting java script exceptions and not able to get the actual Htmlpage. </b> <br/> <br/> Please let us know if you need any more information. <br/> Thanks, </iframe>
1 Attachments

Discussion

  • Ahmed Ashour

    Ahmed Ashour - 2015-06-19

    Hi,

    It is really good that you investigated, and found the offending line.

    MouseEvent.currentTarget is defined for CHROME, FF, IE11.

    I assume that you are using HtmlUnit with IE8 (the default browser).

    Try to use it with BrowserVersion.FIREFOX_38

    As always, please use latest version (2.17 currently).

     
  • Hemendra Yadav

    Hemendra Yadav - 2015-06-23

    Thanks Ahmed,



    I have upgraded HtmlUnit to 2.15 but i am getting the "Javascript compile script" then "illegally formed XML syntax" when receiving response html for XMLHttp request. Please find the attachement as "Response.html" that contains the response received from server.



    I found that HtmlUnit throwing the exception when it is going to add <script> at line 12 of "Response.html" However instead of directly executing the script it should execute the function <b>"AdfDhtmlPage.prototype._applyRichResponse = function (a, b, c, d, e) {"</b> defined in the js attached as "boot.js" at line 6576 and parse the response as per defination in the function applyRichResponse.<br> <br/><br/><br> Can you please help here to identify the issue why htmlUnit is not going execute custom JS function on response html.For your reference i have attached the "log.txt" containing logging statement of execution and stacktrace for the above metioned issue.</p></script>

     

    Last edit: Hemendra Yadav 2015-06-23
  • Ahmed Ashour

    Ahmed Ashour - 2015-06-23

    Hi Hemendra,

    You need to provide your complete java code, so it can be checked against latest snapshot.

    Or you can get it and continue investigating.

    At: com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext.compileString(HtmlUnitContextFactory.java:201)

    there is a string which is sent to the JavaScript to be parsed, print this offending string.

    You really need to upgrade HtmlUnit and use Java 7u80.

    Hope that helps,
    Ahmed

     
  • Ahmed Ashour

    Ahmed Ashour - 2015-06-24

    Hi Hemendra,

    You use a private URL.

    What is needed is a complete case, which can be publicly run, so we can reproduce the issue.

    Otherwise, please get latest snapshot and print the string sent in compileString()

     
  • Hemendra Yadav

    Hemendra Yadav - 2015-06-25

    Hi Ahmed

    The string passed to compileString() method is mentioned below which is part of response received from server attached as "response.xml":

    <![CDATA[AdfPage.PAGE.addComponents(new AdfRichCommandLink('r1:0:pt_region1:1:pt1:t1:0:cl2',{'busyMessage':'Loading App Select SPID','behaviors':new AdfShowPopupBehavior('::fav_popup_menu',null,'cl2','contextMenu'),'partialSubmit':true,'accessKey':'\uffff','text':'Select SPID','inlineStyle':'color:#00319C;'}),new AdfRichCommandLink('r1:0:pt_region1:1:pt1:t1:1:cl2',{'busyMessage':'Loading App Create Port Request','behaviors':new AdfShowPopupBehavior('::fav_popup_menu',null,'cl2','contextMenu'),'partialSubmit':true,'accessKey':'\uffff','text':'Create Port Request','inlineStyle':'color:#00319C;'}),new AdfRichCommandLink('r1:0:pt_region1:1:pt1:t1:2:cl2',{'busyMessage':'Loading App Create Sup Request','behaviors':new AdfShowPopupBehavior('::fav_popup_menu',null,'cl2','contextMenu'),'partialSubmit':true,'accessKey':'\uffff','text':'Create Sup Request','inlineStyle':'color:#00319C;'}),new AdfRichCommandLink('r1:0:pt_region1:1:pt1:t1:3:cl2',{'busyMessage':'Loading App Port Status','behaviors':new AdfShowPopupBehavior('::fav_popup_menu',null,'cl2','contextMenu'),'partialSubmit':true,'accessKey':'\uffff','text':'Port Status','inlineStyle':'color:#00319C;'}),new AdfRichCommandLink('r1:0:pt_region1:1:pt1:t1:4:cl3',{'window_name':'','clientListeners':{click:openUrlInNewBrowserTab},'behaviors':new AdfShowPopupBehavior('::fav_popup_menu',null,'cl3','contextMenu'),'partialSubmit':true,'accessKey':'\uffff','text':'Help','shortDesc':'/content/crossroads/help/tpgui_help/welcome.htm','inlineStyle':'color:#00319C;'}));]]>

    When HtmlUnit is parsing the above script then it is throwing the exception as "message=[illegally formed XML syntax]".Please find attached stacktrace file as "stacktrace1.txt"

    The above exception is thrown while executing the string "<![CDATA[". Please find the more details in below table:

    NameValue
    Parsing Value<!CDATA[
    Class Namenet.sourceforge.htmlunit.corejs.javascript.TokenStream
    Methodint getNextXMLToken()
    Last line executed inside switch case of above method: addToString('[');line number in class "1266"

    After that I have updated the response using WebResponseData which is comming from server and removed the "<![CDATA[", after doing this change it is throwing the exception as: "ReferenceError: "AdfPage" is not defined." Please find attached stacktrace file as "stacktrace2.txt"

    Can you please take a look and suggest what needs to be corrected to run this succesfully.

    Also One observation here that in attached response.xml, htmlunit code is not throwing any exception while parsing the below script

    <script> //&lt;![CDATA[ parent.AdfPage.PAGE.getDataTransferService().processStreamingResponse("parent.AdfPage.PAGE.streamingResponseStarted();"); //]]&gt; &lt;/script&gt; Thanks, Hemendra </script>
     
  • Ahmed Ashour

    Ahmed Ashour - 2015-06-28

    Hi,

    CDATA should not be inside <script>, as the below case is not handled by real browsers (far below).</p> <p>I guess you need to know why AdfPage is not defined.</p> <p>Please put alerts before and after its actual definition 'alert(AdfPage)', and put alerts around the its usage (reference). Possibly HtmlUnit calls the usage before the definition, or there is an exception thrown prevents its definition.</p> <div class="codehilite"><pre><span></span><code><span class="cp">&lt;!DOCTYPE HTML&gt;</span> <span class="p">&lt;</span><span class="nt">html</span><span class="p">&gt;</span> <span class="p">&lt;</span><span class="nt">head</span><span class="p">&gt;</span> <span class="p">&lt;</span><span class="nt">script</span><span class="p">&gt;</span> <span class="o">&lt;!</span><span class="p">[</span><span class="nx">CDATA</span><span class="p">[</span> <span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="nx">test</span><span class="p">()</span><span class="w"> </span><span class="p">{</span> <span class="w"> </span><span class="nx">alert</span><span class="p">(</span><span class="s1">&#39;hello&#39;</span><span class="p">);</span> <span class="w"> </span><span class="p">}</span> <span class="p">]]</span><span class="o">&gt;</span> <span class="w"> </span><span class="p">&lt;/</span><span class="nt">script</span><span class="p">&gt;</span> <span class="p">&lt;/</span><span class="nt">head</span><span class="p">&gt;</span> <span class="p">&lt;</span><span class="nt">body</span> <span class="na">onload</span><span class="o">=</span><span class="s">&#39;test()&#39;</span><span class="p">&gt;</span> <span class="p">&lt;/</span><span class="nt">body</span><span class="p">&gt;</span> <span class="p">&lt;/</span><span class="nt">html</span><span class="p">&gt;</span> </code></pre></div> </script>

     
  • Hemendra Yadav

    Hemendra Yadav - 2015-06-29

    Hi Ahmed,

    The URL is https://mysyniverse.syniverse.com/ and Username/Password : B000749/Htmltset626!

    After login to the above url you will get tab having below links:

    My Home | LNP | Tools | Help

    When clicking on LNP link Manually using browser i am getting the html page having below option:

    Select SPID
    Create Port Request
    Create Sup Request
    Port Status
    Help

    While using HtmlUnit 2.17 API i am not getting the Html page having above options after clicking on LNP link.

    Please find the attached code which i am using.

    ===============================

    Also i find one more thing that below script returned in response when htmlunit going to execute these script they will termianate the function:
    <script-library>/portal/afr/partition/ie/n/default/opt/table-11.1.1.7.0-4050.js</script-library>
    <script-library>/portal/afr/partition/ie/n/default/opt/tree-11.1.1.7.0-4050.js</script-library>

    present at location:
    https://mysyniverse.syniverse.com/portal/afr/partition/ie/n/default/opt/table-11.1.1.7.0-4050.js
    https://mysyniverse.syniverse.com/portal/afr/partition/ie/n/default/opt/tree-11.1.1.7.0-4050.js

    For example I have put the alert in boot-11.1.1.7.0-4050.js inside the below function:

    AdfDhtmlPage.prototype._applyRichResponse = function (a, b, c, d, e) {
    ............................
    ........................
    if (l == "content") {
    l = null;
    b && this._handleRichResponseAction(a);
    var b = [], m = this._getFocusPath(), n = a.childNodes, o = n.length, p;
    if (e != null)
    p = e._clientEventsSet;
    if (p && p[AdfPollEvent.POLL_EVENT_TYPE])
    this._componentsUpdatedByPollEvent = [];
    alert("Checking total length of children of content tag=> "+o); //value of o is 22
    alert("Printing text for checking=> "+AdfAgent.AGENT.getTextContent(a));
    for (a = 0; a < o; a++) {
    alert("Inside For Loop with value of O==> "+o); //here each time the value of o remains 22
    alert("Inside For Loop with temp value of a "+a); // but the last value of a is 9
    .................
    ............................
    }

    The above loop terminate when going to execute the below script

    <script-library>/portal/afr/partition/ie/n/default/opt/table-11.1.1.7.0-4050.js</script-library>

    I have put alerts inside the table js script but these alerts didn't trigger.

     

    Last edit: Hemendra Yadav 2015-06-29
  • Ahmed Ashour

    Ahmed Ashour - 2015-06-30

    Hi Hemendra,

    Which is because script array is not defined.

    The library is big, and I usually try to get a local copy to compare the result with real browsers.

    For the last alert you mentioned, possibly real browser also do not evaluate them too.

    I guess you should try to provide a minimal case, if possible.

     
  • Hemendra Yadav

    Hemendra Yadav - 2015-07-01

    Hi Ahmed,

    I have fixed the above issue by defining script array by modifying the response and for the last alert which i have mentioned is working fine by increasing the timeout from 10000 to webClient.setJavaScriptTimeout(50000);

    But I am not getting the the html page after clicking the LNP link that we get in actual browser. LNP link will be visibile after login in to URL and on home page below link will be visible

    My Home |LNP | Tools | Help

    Can you help us in getting that page, below is the URL of site, username and password:

    Site Link : https://mysyniverse.syniverse.com
    UserName : B000749
    PassWord : Htmltset626!

    Can you please tell me for which scenario you are asking for minimal testcase.

     
  • Hemendra Yadav

    Hemendra Yadav - 2015-07-03

    Hi Ahmed,

    I have attached the java code that i am using and also i have added comments in code at respective places.

    Can please look into it and help us in getting the expected page.

    Thanks,
    Hemendra

     
  • Hemendra Yadav

    Hemendra Yadav - 2015-07-23

    Hi Ahmed,

    I have found one issue with HtmlUnit that is the keycode value of Enter key returned by the browser and htmlunit are different. HtmlUnit returned key code as '10' but the actual browser returned '13'.

    Please find the attached testcase with along with htmlpage.

    It would be good if you provide any workaround.

    Thanks

     

    Last edit: Hemendra Yadav 2015-07-23
  • Ahmed Ashour

    Ahmed Ashour - 2015-07-24

    To be verified in WebDriver, against Chrome/FF/IE driver implementations.

     
  • Hemendra Yadav

    Hemendra Yadav - 2015-07-31

    I have checked with all above browser and found the same behaviour. Can you please provide any workaround.

    Also, I have another question:

    When I called HtmlPage.getElementsByTagName("div"); then sometimes it returns empty list because inside this method HtmlElement.getLocalName() method returns div in uppercase.

    I found that getLocalName method sometimes returns tag name in uppercase and sometimes lowercase but HTML page have div tag in lowercase .

    Can you please tell me why this is happening.

     

    Last edit: Hemendra Yadav 2015-08-03
    • RBRi

      RBRi - 2016-02-12

      The key code issue is now fixed in SVN. You can use the latest snapshot.
      And as Ahmed already mentions: please open a separate issue for all your different problems. Otherwise we are not able to track/fix the issues.
      Will close this issue now, please open a new one if you still have problems with the latest/snapshot version.

       
  • Hemendra Yadav

    Hemendra Yadav - 2015-08-07

    Hi Ahmed,

    Did you get a chance to look into above question.

    Thanks,
    Hemendra

     
  • Ahmed Ashour

    Ahmed Ashour - 2015-08-12

    Hi,

    Please don't re-add new issues for existing tickets, instead create a new one.

    The key code needs verification, after we update WebDriver.

     
  • RBRi

    RBRi - 2016-02-12
    • status: open --> closed
    • assigned_to: HtmlUnit --> RBRi
     
  • sitaram

    sitaram - 2018-08-07

    Dear Sir

    I am also stuck at same position. I am work with html2.27 version .

    I want to read end to end https://mysyniverse.syniverse.com/ . U can use above credential to logged in. Can any one give me idea how i can go about.

    Issue i am facing is I am not able to click select SPID link available using 2.27

    I tried with windoschnageListner but it is not forming proper HtmlPage.

    I am getting error com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "AdfPage" is not defined.

    Please I need help

    Thnak you

     

Log in to post a comment.

MongoDB Logo MongoDB