Using the current version of HttpUnit (1.6), one can't
lookup a normal button (type=button) or a text field
outside a form even with
response.getElementWithId(elementName) as in the
following test:
public void testButton() throws Exception {
Button save = (Button)response.getElementWithID
("save");
assertNotNull(save);
}
where "save" is the id of a normal button without a form.
Possible solution:
----------------
I have investigated the source code of the httpunit1.6
and have found the following bug in the class
(com.meterware.httpunit.ParsedHTML.FormControlFactor
y):
in the method (newControlWithoutForm), i replaced
the following line:
if (element.getNodeName().equalsIgnoreCase( "button" )
with:
if (element.getNodeName().equalsIgnoreCase( "input" )
It is an obvious error since there is no element with
name (button).
Everything then goes smoothly and friendly.
Logged In: YES
user_id=37920
Of course there is an element named <button>. See
<file:///C:/documentation/html4/interact/forms.html#h-17.5>
The problem is, buttons can be defined as either <button> or
<input> and the code was ignoring the latter. It is now
fixed in CVS. Thanks for finding this.