Menu

Package protected form control classes

2004-09-23
2013-04-26
  • James Violette

    James Violette - 2004-09-23

    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
            }

     
    • James Violette

      James Violette - 2004-09-23

      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)
              {
              }

       

Log in to post a comment.

Monday.com Logo