Menu

check a check box???

Help
2003-07-07
2004-08-18
  • Steve Hanks

    Steve Hanks - 2003-07-07

    I am needing some assistance on how to check a checkbox using HTTPUnit.  The checkbox that I need checked is named (not ID) 6 (Don't blame me for the horrible name, I didn't write the JSP - but I have to write some acceptance tests).

    The code that I am using is this:

    form.setParameter("6","6");

    The variable form has been asserted as not null, so the problem does not lie here.  The getParameterValue of parameter 6 before the above call is null, and is "6" after the above call.  Unfortunetely, when I submit my page, the form validation complains because this checkbox has not been checked.  The form validation is done in JavaScript and uses the var.checked property (where var is the checkbox in question).  The HTTPUnit docs show that the checked property should be implemented, but I wonder if the problem lies here. 

    Might someone help me determine what I should try next, or has any concrete proof that the javascript is failing.

     
    • Anonymous

      Anonymous - 2004-08-18

      Hi Steve,

      guess that a checkbox is somehow not a "normal" parameter cause I face a similar problem. I am using
      request.getRequestParameterNames() to get the names of checkbox parameters but this method does not return the names of checkboxes. Seems to just ignores checkboxes.
      Would appreciate help on that problem too.

       
    • David Demmer

      David Demmer - 2004-08-18

      I've seen this with a couple of cases.

      1. the form being submitted did not have the current response w/the checked box from the web conversation. Try getting the form from the getWebConversation.getResponse() and then submitting the form. This does not sound like a solution to your problemn, but FYI.

      2. I resorted to setting the checkbox and/or radio button as an HTMLElement with the following code.

      HTMLElement radio_button = getCurrentPage().getElementWithID(getPortletID() + "_radio_" + index);
              radio_button.getScriptableDelegate().set("checked", new Boolean("true"))

       

Log in to post a comment.

MongoDB Logo MongoDB