Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 958903

Pages: 1
honeymca
Unregistered




testing forms in httpunit
      #34276 - 07/20/06 07:03 AM

how to make test cases for forms using httpunit

Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: testing forms in httpunit [Re: honeymca]
      #41192 - 11/27/06 02:44 AM

WebConversation wc = new WebConversation();
WebRequest request;
request = new PostMethodWebRequest("http://localhost/form.htm");
WebResponse response;
response = wc.getResponse(request);
WebForm[] webform = response.getForms();
String [] fieldsname=webform[0].getParameterNames();
Button[] butttons=webform[0].getButtons();
for (String fieldname : fieldsname){
if(webform[0].isTextParameter(fieldname)) webform[0].setParameter(fieldname,"123456");
else if(webform[0].isMultiValuedParameter(fieldname)) webform[0].setParameter(fieldname,webform[0].getOptionValues(fieldname)[1]);
webform[0].setCheckbox("c",true);
//
}
// webform[0].submit();
System.out.println("cod==="+webform[0].submit().getResponseCode());
System.out.println(webform[0].getParameterValue("name"));
System.out.println(webform[0].getParameterValue("fam"));
System.out.println(webform[0].getParameterValue("c"));
System.out.println(webform[0].getParameterValue("f"));


}


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 7540

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5