Menu

javascript onChange() in HttpUnit

2003-07-30
2003-07-31
  • Arthur Tobin

    Arthur Tobin - 2003-07-30

    Hi
    I'm trying to test a newly developed app using HttpUnit.  On the page there is a Dropdown list, once selected causes the page to submit to the server (onChange())so as to populate another dropdown list, which in turn will cause another onChange event.  Once this is done I fill out the remainder of the form and then hit the submit button.  How can I simulate this?  Essentially there are 2 onChange() Submits before the Submit button is hit.  Any help would be appreciated as I am stuck on this.

    Thanks
    Arthur

    This is the Code that I am using

    WebForm loginForm = response.getForms()[0];
    WebRequest request = loginForm.getRequest();
        HttpUnitOptions.setExceptionsThrownOnScriptError( false );
    request.setParameter( AppProperties.FORM_ELEMENT_startDate, AppProperties.DATA_START_DATE);
        request.setParameter( AppProperties.FORM_ELEMENT_endDate, AppProperties.DATA_END_DATE);
        request.setParameter( AppProperties.FORM_ELEMENT_classID, AppProperties.DATA_CLASS);
        request.setParameter( AppProperties.FORM_ELEMENT_lineOfBusiness, AppProperties.DATA_LINE_OF_BUSINESS);
        request.setParameter( AppProperties.FORM_ELEMENT_assignmentLevel, AppProperties.DATA_ASSIGNMENT_LEVEL);
        request.setParameter( AppProperties.FORM_ELEMENT_assignedName, AppProperties.DATA_ASSIGNED_NAME);
        request.setParameter( AppProperties.FORM_ELEMENT_shortDesc, AppProperties.DATA_SHORT_DESCRIPTION);
        request.setParameter( AppProperties.FORM_ELEMENT_detailedDesc, AppProperties.DATA_LONG_DESCRIPTION);
        //request.setParameter( AppProperties.FORM_ELEMENT_ATTACH_file, AppProperties.DATA_ATTACH_FILE);
        request.setParameter( AppProperties.FORM_ELEMENT_category, AppProperties.DATA_CATEGORY);
        request.setParameter( AppProperties.FORM_ELEMENT_subCategory, AppProperties.DATA_SUB_CATEGORY);

    response = conversation.getResponse( request );

    This is the javascript code:
    <script type="text/javascript">
    function submit(){
        createTaskForm.submit();
    }

    function classSubmit(){
        document.createTaskForm.classChanged.value="true";
        createTaskForm.submit();
    }
    </script>

    which is called by :

    <select name='classID'  onchange="javascript:classSubmit()" >

    This is the error that I am receiving, Category is blank until the first onChange, but it should be a 100 for the final submit

    testCreateTaskFormSubmitValidData(com.decare.test.CreateTaskUseCase)com.meterware.httpunit.MissingParameterValueException: Parameter 'category' must have the value ''. Attempted to set it to: { 100 }
        [junit]     void com.meterware.httpunit.FormControl.claimValueIsRequired(java.util.List, java.lang.String)
        [junit]         FormControl.java:259
        [junit]     void com.meterware.httpunit.TextFormControl.claimValueIsRequired(java.util.List)
        [junit]         FormControl.java:667
        [junit]     void com.meterware.httpunit.TextFormControl.claimRequiredValues(java.util.List)
        [junit]         FormControl.java:662
        [junit]     void com.meterware.httpunit.FormParameter.setValues(java.lang.String[])
        [junit]         FormParameter.java:89
        [junit]     void com.meterware.httpunit.WebForm.setParameter(java.lang.String, java.lang.String[])
        [junit]         WebForm.java:522
        [junit]     void com.meterware.httpunit.WebForm.setParameter(java.lang.String, java.lang.String)
        [junit]         WebForm.java:515
        [junit]     void com.meterware.httpunit.WebRequest.setParameter(java.lang.String, java.lang.String)
        [junit]         WebRequest.java:134
        [junit]     void com.decare.test.CreateTaskUseCase.testCreateTaskFormSubmitValidData()

     
    • Arthur Tobin

      Arthur Tobin - 2003-07-31

      Can anybody help me with as I am really bogged down on it, I have a dropdwon, which onChange() goes back to the server, so as to get data to populate another dropdown box, after that this happens once more, before I carry on filling out the form and then hitting the submit button.

      Badly stuck on it
      Thanks
      Arthur

       

Log in to post a comment.

Auth0 Logo