Window.open Error

Sai Surya <[email protected]> Tue, 10 May 2011 17:58:04 +0800
Newsgroups gmane.comp.web.httpunit.devel
Message-ID <[email protected]>
--===============1466473380084377155==
Content-Type: multipart/alternative;
	boundary="_4d862a8c-a725-46fc-a8e4-bb69695ff5b3_"

--_4d862a8c-a725-46fc-a8e4-bb69695ff5b3_
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit


Hi,

I am using HttpUnit 1.7 to test my web site. I am opening a new window using 'window.open' by clicking the button. 
Getting the following exception.

java.lang.NoSuchFieldError: instance
    at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.toStringIfNotUndefined(JavaScript.java:364)
    at com.meterware.httpunit.javascript.JavaScript$Window.jsFunction_open(JavaScript.java:546)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)


I am opening popup like this: popup-test.html
<form name="testButtonForm">
      <input type="button" ID="clickButton" name="clickButton" value="Tagit" onclick="javascript:window.open('http://www.google.com','google')"/>
</form>

I am using HttpUnit to open popup like this:
       WebConversation wc = new WebConversation();
        WebResponse resp = null;
        WebForm form = null;
        Button button = null;
        WebLink link = null;
        
        WebRequest req = new GetMethodWebRequest("http://localhost:8082/vb-scenarios/html/scenario-frame/popup-test.html");
        try {
            
            resp = wc.getResponse(req);
            form = resp.getFormWithName("testButtonForm");            
            button = form.getButtonWithID("clickButton");                        
            button.click();
        } catch (Exception e) {
            //Exception handling
        }

Is there anything wrong with the above code, how do I get the response of the popup window.


Thanks in advance,
Surya.
        
 		 	   		  
--_4d862a8c-a725-46fc-a8e4-bb69695ff5b3_
Content-Type: text/html; charset="gb2312"
Content-Transfer-Encoding: 8bit

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi,<br><br>I am using HttpUnit 1.7 to test my web site. I am opening a new window using 'window.open' by clicking the button. <br>Getting the following exception.<br><br>java.lang.NoSuchFieldError: instance<br>&nbsp;&nbsp;&nbsp; at com.meterware.httpunit.javascript.JavaScript$JavaScriptEngine.toStringIfNotUndefined(JavaScript.java:364)<br>&nbsp;&nbsp;&nbsp; at com.meterware.httpunit.javascript.JavaScript$Window.jsFunction_open(JavaScript.java:546)<br>&nbsp;&nbsp;&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>&nbsp;&nbsp;&nbsp; at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>&nbsp;&nbsp;&nbsp; at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>&nbsp;&nbsp;&nbsp; at java.lang.reflect.Method
 .invoke(Method.java:597)<br><br><br><b>I am opening popup like this:</b> <b>popup-test.html</b><br>&lt;form name="testButtonForm"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type="button" ID="clickButton" name="clickButton" value="Tagit" onclick="javascript:window.open('http://www.google.com','google')"/&gt;<br>&lt;/form&gt;<br><br><b>I am using HttpUnit to open popup like this:</b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WebConversation wc = new WebConversation();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WebResponse resp = null;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WebForm form = null;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Button button = null;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WebLink link = null;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&
 nbsp;&nbsp; WebRequest req = new GetMethodWebRequest("http://localhost:8082/vb-scenarios/html/scenario-frame/<b>popup-test.html</b>");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; resp = wc.getResponse(req);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; form = resp.getFormWithName("testButtonForm");&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; button = form.getButtonWithID("clickButton");&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; button.click();<br>&nbs
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch (Exception e) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Exception handling<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>Is there anything wrong with the above code, how do I get the response of the popup window.<br><br><br>Thanks in advance,<br>Surya.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br> 		 	   		  </body>
</html>
--_4d862a8c-a725-46fc-a8e4-bb69695ff5b3_--


--===============1466473380084377155==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
--===============1466473380084377155==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop

--===============1466473380084377155==--