Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.
honeymca
Unregistered
|
|
how to make test cases for forms using httpunit
|
Unregistered
|
|
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"));
}
|
|
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
|
|
|
|
|
|
Powered by UBB.threads™ 6.5.5