There's a patch for the setResponse() -> see the submitted patches to JWebUnit.

Thanks, Jason

rcromer wrote:

I’m trying to test a form that has a multiple submit buttons without names but does have different values.    

i.e.

<input type=”submit” value=”action1”>

<input type=”submit” value=”action2”>

 

Since I couldn’t figure out how to use jWebUnit to submit the form by input tag’s value attribute, I’ve tried to create a new method in my test class as follows:

 

private boolean clickSubmitWithText(String attributeValue) {

        boolean submitted = false;

 

        HttpUnitDialog dialog = this.getDialog();

        WebForm webForm = dialog.getForm();

        SubmitButton[] submitButtons = webForm.getSubmitButtons();

 

        for (int i = 0; i < submitButtons.length; i++) {

            if (submitButtons[i].getValue().equals(attributeValue)) {

                try {

                    submitButtons[i].click();

                    submitted = true;

                } catch (IOException e) {

                } catch (SAXException e) {

                }

            }

        }       

        return submitted;

}

 

Public void testSignUp() {

 

      setWorkingForm("form1");    

      boolean clicked = clickSubmitWithText("Sign Up");

      assertEquals("Sign Up button exist", true, clicked);

      assertTitleEquals("Virtual phone - Options page");

}

 

It fails on the last insert.  Apparentlyl the page response is lost in the clickSubmit method.  How do I bring that back into the view of WebTestCase?   I don’t see a setDialog method if that’s what’s needed.

 

 

Regards,

Rick

 

Reply via email to