How to validate radio buttons using HttpUnit
Sandhya Kollath <[email protected]> Fri, 31 Oct 2008 16:12:27 -0700 (PDT)
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am trying to write a test case to simulate a radio option using HttpUnit.
My form looks like this:
<form method="post">
<table>
<tr>
<td>
<input type="radio" name="phoneList" value="false"/>Existing Mobile Number
Select a number
<input type="hidden" name="wlw-select_key:{actionForm.selectedNumber}OldValue" value="true" />
<select name="wlw-select_key:{actionForm.selectedNumber}">
<option value="1231231234">1231231234</option>
<option value="2342342345">2342342345</option></select>
</td>
<td>
<input type="radio" name="phoneList" value="true" checked="checked"/>New Mobile Number
Number
<input type="text" name="{actionForm.areaCode}" maxlength="3" size="3" title="Area code" onkeyup="return autoTab(this, 3, event);" />
<input type="text" name="{actionForm.firstThree}" maxlength="3" size="3" title="First 3" onkeyup="return autoTab(this, 3, event);" />
<input type="text" name="{actionForm.lastFour}" maxlength="4" size="4" title="Last 4" onkeyup="return autoTab(this, 4, event);" />
</td>
</tr>
</table>
...
</form>
and my test case looks like this;
WebForm[] forms = response.getForms();
WebForm form = forms[0];
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
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop