File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes How to use HttpUnit and JsUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to use HttpUnit and JsUnit" Watch "How to use HttpUnit and JsUnit" New topic
Author

How to use HttpUnit and JsUnit

Shrikant Kulkarni
Ranch Hand

Joined: May 10, 2005
Posts: 42
Hi All,
I am facing a problem while testing a JSP page which contains some Javascript code.I am using httpunit for testing.

Here is my test method:
======================================================================
public void testGoodLogin() throws Exception {
WebConversation conversation=null;
WebResponse response=null;
WebRequest request =null;
String url = "http://localhost:8080/digite/Request?Key=login";
try{
conversation = new WebConversation();
request = new GetMethodWebRequest( url );
response = conversation.getResponse(request);
response = conversation.getCurrentPage();
WebForm form = response.getFormWithName("loginForm");
form.setParameter("loginId","admin");
form.setParameter("password","111111");
response = form.submit();
}
catch(Exception e) {
e.printStackTrace();
fail("Failure::::"+ e);
}
}
======================================================================

When we submit form after giving valid userId and password, the control should move to inbox_open page. When this login page reads a javascript function openFrameworkWindow(), i get an error like:

com.meterware.httpunit.ScriptException: Script 'openFrameworkWindow('/digite/Request?Key=framework_main&ContainedURL=inbox_open');' failed: org.mozilla.javascript.EcmaError: TypeError: Cannot set property "location" of undefined to "/digite/Request?Key=framework_main&ContainedURL=inbox_open" (httpunit#260)

I found out that, httpunit doesnot support the javascript code present in the openFrameworkWindow() function. So now i am trying to use JsUnit for javascript testing.
Now the problem is how to integrate HttpUnit and JsUnit ?

Any help pls.

Shrikant
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use HttpUnit and JsUnit