Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebForm


        WebRequest request = new GetMethodWebRequest(url.toString());
        WebResponse response = conversation.getResponse(request);

        assertEquals(1, response.getForms().length);

        WebForm webForm = response.getForms()[0];

        webForm.setParameter("j_username", "tomcat");
        webForm.setParameter("j_password", "tomcat");

        webForm.getSubmitButtons()[0].click();

        response = conversation.getCurrentPage();
        LOGGER.debug("Response from IDP: "+response.getText());
        LOGGER.debug("SP1-URL: "+serviceProviderPostURL);
        LOGGER.debug("webURI: "+webURI);
View Full Code Here


        String uri = URI.create("http://www.taobao.com/readfile" + "?file=" + htmlfile).normalize().toString();

        // ȡ�ó�ʼҳ���form
        WebResponse response = client.getResponse(new GetMethodWebRequest(uri));

        WebForm form = response.getFormWithName("myform");

        // ȡ���ύform��request
        WebRequest request = form.getRequest();

        request.setParameter("myparam", new String[] { "hello",
                "中华人民共和国" });

        try {
View Full Code Here

     */
    public void testStrutsPages() throws Exception {
        WebConversation wc = new WebConversation();
        wc.getResponse(requestUrl("/TestInput.do"));
        {
            WebForm form = wc.getCurrentPage().getForms()[0];
            form.setParameter("givenName", "Archie");
            form.setParameter("familyName", "Trajano");
            form.submit();
        }
        {
            WebForm form = wc.getCurrentPage().getForms()[0];
            assertEquals("Archie", form.getParameterValue("givenName"));
            assertEquals("Trajano", form.getParameterValue("familyName"));
        }
    }
View Full Code Here

        // Test the search page
        WebLink wl = resp.getLinkWith("Search");
        wl.click();
        resp = wc.getCurrentPage();
        // check if the search returns more than one result for "cat
        WebForm form = resp.getForms()[0];
        assertEquals("on", form.getParameterValue("searchForm:searchTags"));
        String searchText = "cat";
        form.setParameter("searchForm:searchString", searchText);
        form.submit();
        resp = wc.getCurrentPage();
        WebTable resultTable = resp.getTableStartingWithPrefix("Map");
        assertTrue(resultTable.getRowCount() > 2);
    }
View Full Code Here

     * @param value parameter value
     * @return new web response
     * @throws Exception
     */
    private WebResponse submitWithParam(WebResponse orig, String formname, String paramname, String value) throws Exception {
        WebForm form = orig.getFormWithName(formname);
        form.setParameter(paramname,value);
        return form.submit();
    }
View Full Code Here

        /* check getInts(n) */
        resp = submitWithParam(resp,"getInts","getInts","n");
        checkTextStart(resp,"getInts","[I@");

        /* check getString(bar,foo) */
        WebForm form = resp.getFormWithName("getString2");
        form.setParameter("getString1","'bar'");
        form.setParameter("getString2","'foo'");
        resp = form.submit();
        checkText(resp,"getString2","foo");

        /* TODO other getters with default values */

        /* check all */
 
View Full Code Here

     * @param value parameter value
     * @return new web response
     * @throws Exception
     */
    private WebResponse submitWithParam(WebResponse orig, String formname, String paramname, String value) throws Exception {
        WebForm form = orig.getFormWithName(formname);
        form.setParameter(paramname,value);
        return form.submit();
    }
View Full Code Here

        /* check get('JSESSIONID') */
        resp = submitWithParam(resp,"get","get","JSESSIONID");
        checkTextStart(resp,"get","javax.servlet.http.Cookie");

        /* check add('foo','bar') */
        WebForm form = resp.getFormWithName("add2");
        form.setParameter("add1","foo");
        form.setParameter("add2","bar");
        resp = form.submit();
        resp = submitWithParam(resp,"get","get","foo");
        checkTextStart(resp,"get","javax.servlet.http.Cookie");
    }
View Full Code Here

        /* check getInts(n) */
        resp = submitWithParam(resp,"getInts","getInts","n");
        checkTextStart(resp,"getInts","[I@");

        /* check getString(bar,foo) */
        WebForm form = resp.getFormWithName("getString2");
        form.setParameter("getString1","'bar'");
        form.setParameter("getString2","'foo'");
        resp = form.submit();
        checkText(resp,"getString2","foo");

        /* TODO other getters with default values */

        /* check all */
 
View Full Code Here

            new UploadFileSpec(filename.substring(filename.lastIndexOf("/")),
                    this.getClass().getClassLoader().getResourceAsStream(filename),
                    "text/plain")
        };
        HttpUnitDialog dialog = getDialog();
        WebForm form = dialog.getForm();
        form.setParameter("formFile", testUploads);
    }
View Full Code Here

TOP

Related Classes of com.meterware.httpunit.WebForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.