HttpUnit
[See all forum posts about HttpUnit]
Validating Radio Buttons Using HttpUnit
Hi,
I am trying to write a test case to simulate a radio option using HttpUnit.
My form looks like this:
and my test case looks like this;
WebForm[] forms = response.getForms();
WebForm form = forms[0];
String number = phoneNumber.getArea()+phoneNumber.getThree()+phoneNumber.getFour();
System.out.println("PHONE NUMBER TO SET: " + number);
String radioGroupName = "phoneList";
String[] options = form.getOptions(radioGroupName); //this returns the labels of the radio button
String[] optionsValues = form.getOptionValues(radioGroupName); //this returns true and false as per HttpUnit API
for (int i = 0; i < options.length; i++) {
if (options[i].equals("Existing Mobile Number")) {
System.out.println("Existing");
//do something
} else {
System.out.println("New");
//do something
}
}
For some reason, form.getOptions(radioGroupName) returns empty string. How do I decide which radio option is selected?
Any advise is highly appreciated.
Thanks.
Sandy
Author: sandy_ajit Date: October 31, 2008 at 18:08
Hi,
I am trying to write a test case to simulate a radio option using HttpUnit.
My form looks like this:
and my test case looks like this;
WebForm[] forms = response.getForms();
WebForm form = forms[0];
String number = phoneNumber.getArea()+phoneNumber.getThree()+phoneNumber.getFour();
System.out.println("PHONE NUMBER TO SET: " + number);
String radioGroupName = "phoneList";
String[] options = form.getOptions(radioGroupName); //this returns the labels of the radio button
String[] optionsValues = form.getOptionValues(radioGroupName); //this returns true and false as per HttpUnit API
for (int i = 0; i < options.length; i++) {
if (options[i].equals("Existing Mobile Number")) {
System.out.println("Existing");
//do something
} else {
System.out.println("New");
//do something
}
}
For some reason, form.getOptions(radioGroupName) returns empty string. How do I decide which radio option is selected?
Any advise is highly appreciated.
Thanks.
Sandy
Author: sandy_ajit Date: October 31, 2008 at 18:08
[Write Review]