Is there a reason why httpunit form control classes are not public?
I am using HttpUnit to test my page and would like to access com.meterware.httpunit.HiddenFieldFormControl to see its value and assert whether or not its value is what I expected.
However, when I try to use this class, I find the definition is package-protected.
Is there a reason why httpunit form control classes are not public?
I am using HttpUnit to test my page and would like to access com.meterware.httpunit.HiddenFieldFormControl to see its value and assert whether or not its value is what I expected.
However, when I try to use this class, I find the definition is package-protected.
try
{
HTMLElement[] tmpElements = response.getElementsWithName(
getBadgeWidgetName());
HiddenFieldFormControl badgeWidget =
(HiddenFieldFormControl)tmpElements[0];
String badgeValue = (String) badgeWidget get("value");
assertEquals(getBadge(),badgeValue);
} catch (SAXException e)
{ // handle error
}
After a little digging, I saw the getScriptableDelegate() method and this works fine.
WebResponse response = session.getCurrentPage();
try
{
HTMLElement[] tmpElements = response.getElementsWithName(
getBadgeWidgetName());
HTMLElement badgeWidget = tmpElements[0];
Input inputValue = (Input)badgeWidget.getScriptableDelegate();
String badgeValue = (String)inputValue.get("value");
assertEquals(getBadge(),badgeValue);
} catch (SAXException e)
{
}