JS window.open crashes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

JS window.open crashes

Gyetvai Balázs

 

 

[hidden email]

 

Hi,

and thanks for any hint.

 

I am using HtmlUnit 2.5

I am trying to click on a link with the following Href attribute:

 

javascript:window.open('https://www.apps.amway.hu/shop/los/los.aspx?lng=hu', 'points_window', 'width=830,height=580,location=0,menubar=0,resizable=1,scrollbars=1,status=1,titlebar=0,toolbar=0');void(0);

 

It is a pop-up window. The WebWindowListener catches the window but then it crashes.

 

 

My code:

 

link = (HtmlAnchor) page.getFirstByXPath("//*[@id=\"content\"]/div[2]/div[2]/div[3]/a");

page= (HtmlPage) link.click(); 

 

Stack:

 

com.gargoylesoftware.htmlunit.ScriptException: Exception invoking open

======= EXCEPTION START ========

Exception class=[java.lang.RuntimeException]

com.gargoylesoftware.htmlunit.ScriptException: Exception invoking open

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:894)

       at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)

       at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:775)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:751)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:739)

       at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:910)

       at com.gargoylesoftware.htmlunit.html.HtmlAnchor.doClickStateUpdate(HtmlAnchor.java:133)

       at com.gargoylesoftware.htmlunit.html.HtmlAnchor.doClickStateUpdate(HtmlAnchor.java:211)

       at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:999)

       at com.gargoylesoftware.htmlunit.html.HtmlAnchor.click(HtmlAnchor.java:83)

       at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:944)

       at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:884)

       at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:865)

       at PopUpAmw.PopUpAmw.main(PopUpAmw.java:191)

Caused by: java.lang.RuntimeException: Exception invoking open

       at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:182)

       at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:448)

       at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1540)

       at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800)

       at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)

       at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:413)

       at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:292)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264)

       at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:766)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879)

       ... 14 more

Caused by: com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "length" from undefined (https://www.apps.amway.hu/Shop/JS/Tealeaf/TeaLeaf.js#270)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:894)

       at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)

       at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:824)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:796)

       at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:2454)

       at com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.executeEventListeners(EventListenersContainer.java:259)

       at com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:325)

       at com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget.fireEvent(EventTarget.java:188)

       at com.gargoylesoftware.htmlunit.html.DomElement$2.run(DomElement.java:1389)

       at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)

       at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)

       at com.gargoylesoftware.htmlunit.html.DomElement.fireEvent(DomElement.java:1394)

       at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1201)

       at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:253)

       at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:524)

       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:391)

       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:309)

       at com.gargoylesoftware.htmlunit.WebClient.openWindow(WebClient.java:874)

       at com.gargoylesoftware.htmlunit.javascript.host.Window.open(Window.java:453)

       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

       at java.lang.reflect.Method.invoke(Method.java:498)

       at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:153)

       ... 24 more

Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (https://www.apps.amway.hu/Shop/JS/Tealeaf/TeaLeaf.js#270)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3940)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3951)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1492)

       at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1247)

       at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800)

       at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:815)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879)

       ... 48 more

Enclosed exception:

java.lang.RuntimeException: Exception invoking open

       at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:182)

       at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:448)

       at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1540)

       at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800)

       at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)

       at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:413)

       at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:292)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264)

       at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:766)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879)

       at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)

       at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:775)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:751)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:739)

       at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:910)

       at com.gargoylesoftware.htmlunit.html.HtmlAnchor.doClickStateUpdate(HtmlAnchor.java:133)

       at com.gargoylesoftware.htmlunit.html.HtmlAnchor.doClickStateUpdate(HtmlAnchor.java:211)

       at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:999)

       at com.gargoylesoftware.htmlunit.html.HtmlAnchor.click(HtmlAnchor.java:83)

       at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:944)

       at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:884)

       at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:865)

       at PopUpAmw.PopUpAmw.main(PopUpAmw.java:191)

Caused by: com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "length" from undefined (https://www.apps.amway.hu/Shop/JS/Tealeaf/TeaLeaf.js#270)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:894)

       at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)

       at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:824)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:796)

       at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:2454)

       at com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.executeEventListeners(EventListenersContainer.java:259)

       at com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:325)

       at com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget.fireEvent(EventTarget.java:188)

       at com.gargoylesoftware.htmlunit.html.DomElement$2.run(DomElement.java:1389)

       at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)

       at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)

       at com.gargoylesoftware.htmlunit.html.DomElement.fireEvent(DomElement.java:1394)

       at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1201)

       at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:253)

       at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:524)

       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:391)

       at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:309)

       at com.gargoylesoftware.htmlunit.WebClient.openWindow(WebClient.java:874)

       at com.gargoylesoftware.htmlunit.javascript.host.Window.open(Window.java:453)

       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

       at java.lang.reflect.Method.invoke(Method.java:498)

       at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:153)

       ... 24 more

Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (https://www.apps.amway.hu/Shop/JS/Tealeaf/TeaLeaf.js#270)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3940)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3951)

       at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1492)

       at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1247)

       at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800)

       at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$4.doRun(JavaScriptEngine.java:815)

       at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:879)

       ... 48 more

======= EXCEPTION END ========

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user
Reply | Threaded
Open this post in threaded view
|

Re: JS window.open crashes

Ronald Brill
Hi Gyetvai

>and thanks for any hint.
>I am using HtmlUnit 2.5

HtmlUnit 2.5 is really outdated.  Please use the latest version or even better the latest snapshot (details are available at the web page).
Sorry but we can't support old versions.


>I am trying to click on a link with the following Href attribute:
>
>javascript:window.open('https://www.apps.amway.hu/shop/los/los.aspx?lng=hu',
>'points_window',
>'width=830,height=580,location=0,menubar=0,resizable=1,scrollbars=1,status=1
>,titlebar=0,toolbar=0');void(0);

The javascript here is not the problem. There seems to be some javascript in the new window executed after the window opens. This javascript fails.

>It is a pop-up window. The WebWindowListener catches the window but then it
>crashes.


    RBRi
    --------------------------
    WETATOR
    Smart web application testing
    http://www.wetator.org

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Htmlunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-user