Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebForm


   
    // Click the Sign In link
    resp = resp.getLinkWith("Sign In").click();
   
    // Enter the username/password in the form
    WebForm form = resp.getForms()[1];
    form.setParameter( "j_username", userName );
    form.setParameter( "j_password", password );
   
    // Submit
    return form.submit();
  }
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

        client = servletRunner.newClient();

        // 取得初始页面form.html
        WebResponse response = client.getResponse(new GetMethodWebRequest("http://localhost/myservlet"));

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

        // 取得提交form的request
        WebRequest request = form.getRequest();

        request.setParameter("myparam", "中华人民共和国");
        request.selectFile("myfile", new File(srcdir, "smallfile.txt"));

        File nonAsciiFile = 中文文件名;
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 testVersion() throws Exception {
        WebConversation conversation = new WebConversation();
        // Fill the form and submit it
        WebRequest request = new GetMethodWebRequest(getServerUrl());
        WebResponse response = conversation.getResponse(request);
        WebForm formUMLText = response.getForms()[0];
        formUMLText.setParameter("text", "version");
        response = formUMLText.submit();
        // Analyze response
        WebForm[] forms = response.getForms();
        assertEquals(2, forms.length);
        // Ensure the Text field is correct
        assertEquals("version", forms[0].getParameterValue("text"));
View Full Code Here

    public void testEmptyText() throws Exception {
        WebConversation conversation = new WebConversation();
        // Fill the form and submit it
        WebRequest request = new GetMethodWebRequest(getServerUrl());
        WebResponse response = conversation.getResponse(request);
        WebForm formUMLText = response.getForms()[0];
        formUMLText.setParameter("text", "");
        response = formUMLText.submit();
        // Analyze response
        WebForm[] forms = response.getForms();
        assertEquals(2, forms.length);
        // Ensure the Text field is empty
        assertNull(forms[0].getParameterValue("text"));
View Full Code Here

    public void testEmptyUrl() throws Exception {
        WebConversation conversation = new WebConversation();
        // Fill the form and submit it
        WebRequest request = new GetMethodWebRequest(getServerUrl());
        WebResponse response = conversation.getResponse(request);
        WebForm formUrl = response.getForms()[1];
        formUrl.setParameter("url", "");
        response = formUrl.submit();
        // Analyze response
        WebForm[] forms = response.getForms();
        assertEquals(2, forms.length);
        // Ensure the Text field is empty
        assertNull(forms[0].getParameterValue("text"));
View Full Code Here

    public void testDitaaText() throws Exception {
        WebConversation conversation = new WebConversation();
        // Fill the form and submit it
        WebRequest request = new GetMethodWebRequest(getServerUrl());
        WebResponse response = conversation.getResponse(request);
        WebForm formDitaaText = response.getForms()[0];
        formDitaaText.setParameter("text", "@startditaa \n*--> \n@endditaa");
        response = formDitaaText.submit();
        // Analyze response
        WebForm[] forms = response.getForms();
        assertEquals(2, forms.length);
        // Ensure the Text field is correct
        assertTrue(forms[0].getParameterValue("text").startsWith("@startditaa"));
View Full Code Here

    public void testImageMap() throws Exception {
        WebConversation conversation = new WebConversation();
        // Fill the form and submit it
        WebRequest request = new GetMethodWebRequest(getServerUrl());
        WebResponse response = conversation.getResponse(request);
        WebForm formText = response.getForms()[0];
        formText.setParameter("text", "@startuml \nBob -> Alice : [[http://yahoo.com]] Hello \n@enduml");
        response = formText.submit();
        // Analyze response
        // Ensure the generated image is present
        assertNotNull(response.getImageWithAltText("PlantUML diagram"));
        // Ensure the image map is present
        HTMLElement[] maps = response.getElementsByTagName("map");
View Full Code Here

    // Click the add link
    resp = resp.getLinkWith(Util.getBundle("view", "buttonAddAddress")).click();
   
    // Enter the new data in the form
    WebForm form = resp.getForms()[1];

    // Make sure this is a new form
    assertEquals(form.getParameterValue("{actionForm.name}"), "");
   
    // Set the new values
    form.setParameter( "{actionForm.name}", "TestAddress" );
    form.setParameter( "{actionForm.addr1}", "1234 Main Street" );
    form.setParameter( "{actionForm.addr2}", "Apt 123" );
    form.setParameter( "{actionForm.city}", "Seattle" );
    form.setParameter( "{actionForm.state}", "WA" );
    form.setParameter( "{actionForm.zip}", "98104" );
    form.setParameter( "{actionForm.country}", "USA" );
    form.setParameter( "{actionForm.phone}", "206-333-1234" );
   
    // Submit
    resp = form.submit();
   
    // Make sure the address took
    WebTable table = resp.getTableWithID("address_TestAddress");
    assertNotNull(table);
    TableCell cell = table.getTableCell(0, 0);
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.