Examples of HtmlForm


Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

        HtmlPage resultPage = null;
        WebResponse resultResponse= null;
        boolean formfound = false;
        for (Iterator iter = forms.iterator(); formfound != true && iter.hasNext();) {
            HtmlForm form = (HtmlForm) iter.next();

            if ("loginAction".equals(form.getActionAttribute())) {
                formfound = true;
                HtmlInput login = form.getInputByName("login");
                HtmlInput password = form.getInputByName("password");
                login.setValueAttribute("test");
                password.setValueAttribute("password");

                resultPage = (HtmlPage) form.submit();
                // Check response from servlet
                resultResponse = resultPage.getWebResponse();
                assertTrue(resultResponse.getStatusCode() <= 200);

             
                String response = resultResponse.getContentAsString();
                assertTrue(-1 != response.indexOf("Account Information for"));
                assertTrue(-1 != response.indexOf("Test"));
                assertTrue(-1 != response.indexOf("134-42-6231"));
                assertTrue(-1 != response.indexOf("123.43"));
                assertTrue(-1 != response.indexOf("134-43-3941"));
                assertTrue(-1 != response.indexOf("23.12"));

                Pattern pat = Pattern.compile("LU.*7", Pattern.DOTALL);
                Matcher test = pat.matcher(response);
                assertTrue(test.find());
            }

        }
        forms = resultPage.getForms();
       
        formfound = false;
        for(Iterator iter = forms.iterator();  formfound != true && iter.hasNext();) {
            HtmlForm form = (HtmlForm) iter.next();

            if ("purchaseStock.jsp".equals(form.getActionAttribute())) {
                formfound = true;
                resultPage = (HtmlPage) form.submit();
            }

        }
        assertTrue(formfound);
        forms = resultPage.getForms();
        formfound = false;
        for (Iterator iter = forms.iterator(); formfound != true && iter.hasNext();) {
            HtmlForm form = (HtmlForm) iter.next();

            if ("FormServlet".equals(form.getActionAttribute())) {
                formfound = true;

                HtmlInput login = form.getInputByName("symbol");
                HtmlInput password = form.getInputByName("quantity");
                login.setValueAttribute("EDS");
                password.setValueAttribute("131");
               
                resultPage = (HtmlPage) form.submit();
                // Check response from servlet
                resultResponse = resultPage.getWebResponse();
                assertTrue(resultResponse.getStatusCode() <= 200);

            
                String response = resultResponse.getContentAsString();
                assertTrue(-1 != response.indexOf("Account Information for"));
                assertTrue(-1 != response.indexOf("Test"));
                assertTrue(-1 != response.indexOf("134-42-6231"));
                assertTrue(-1 != response.indexOf("123.43"));
                assertTrue(-1 != response.indexOf("134-43-3941"));
                assertTrue(-1 != response.indexOf("23.12"));

                Pattern pat = Pattern.compile("LU.*7", Pattern.DOTALL);
                Matcher test = pat.matcher(response);
                assertTrue(test.find());
                pat = Pattern.compile("EDS.*131", Pattern.DOTALL);
                test = pat.matcher(response);
                assertTrue(test.find());

            }

        }
        assertTrue(formfound);
        forms = resultPage.getForms();
        formfound = false;
        for (Iterator iter = forms.iterator(); formfound != true && iter.hasNext();) {
            HtmlForm form = (HtmlForm) iter.next();

            if ("stockSale.jsp".equals(form.getActionAttribute())) {
//                System.err.println(form.asText());
               
               
               
                Pattern pat = Pattern.compile("EDS.*131", Pattern.DOTALL);
               
                Matcher test = pat.matcher(form.asText());
                if(!test.find()) continue;

               
               
               
                formfound = true;
                resultPage = (HtmlPage) form.submit();
                // Check response from servlet
                resultResponse = resultPage.getWebResponse();
                assertTrue(resultResponse.getStatusCode() <= 200);


            }

        }
        forms = resultPage.getForms();
       
       
       
        formfound = false;
        for(Iterator iter = forms.iterator();  formfound != true && iter.hasNext();) {
            HtmlForm form = (HtmlForm) iter.next();

            if ("FormServlet".equals(form.getActionAttribute())) {
                formfound = true;

               
                HtmlInput password = form.getInputByName("quantity");
               
                password.setValueAttribute("131");

                resultPage = (HtmlPage) form.submit();
                // Check response from servlet
                resultResponse = resultPage.getWebResponse();
                assertTrue(resultResponse.getStatusCode() <= 200);

               
                String response = resultResponse.getContentAsString();
                assertTrue(-1 != response.indexOf("Account Information for"));
                assertTrue(-1 != response.indexOf("Test"));
                assertTrue(-1 != response.indexOf("134-42-6231"));
                assertTrue(-1 != response.indexOf("123.43"));
                assertTrue(-1 != response.indexOf("134-43-3941"));
                assertTrue(-1 != response.indexOf("23.12"));

                Pattern pat = Pattern.compile("LU.*7", Pattern.DOTALL);
                Matcher test = pat.matcher(response);
                assertTrue(test.find());
                // pat = Pattern.compile("EDS.*131", Pattern.DOTALL);
                // test = pat.matcher(response);
                //                assertFalse(test.find());


            }

        }
        assertTrue(formfound);
       
        forms = resultPage.getForms();
        formfound = false;
        for (Iterator iter = forms.iterator(); formfound != true && iter.hasNext();) {
            HtmlForm form = (HtmlForm) iter.next();

            if ("loginAction".equals(form.getActionAttribute())) {
                formfound = true;
               
                // FIXME this seems to performs a log-in again instead of logout...
                 resultPage = (HtmlPage) form.submit();

            }

        }
        assertTrue(formfound);
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

    Iterator iter = forms.iterator();
   
    // Iterate over all forms on page, should only be one.
    while(iter.hasNext())
    {
      HtmlForm form = (HtmlForm)iter.next();
      // Get the "name" form input field
      HtmlInput login = form.getInputByName("name");
      System.err.println(login.getValueAttribute());
      Page resultPage = form.submit();
      // Check response from servlet
      WebResponse resultResponse  = resultPage.getWebResponse();
      assertTrue(resultResponse.getStatusCode() <= 200);
     
      // TODO Check response content..
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

        //webClient.waitForBackgroundJavaScriptStartingBefore(100000);
        webClient.setAjaxController(new NicelyResynchronizingAjaxController());

        HtmlPage page = (HtmlPage) webClient.getPage("http://localhost:8080/store/store.html");

        HtmlForm form = (HtmlForm) page.getFormByName("catalogForm");

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }
       
        HtmlCheckBoxInput catalogItems = (HtmlCheckBoxInput) form.getInputByName("items");

        System.out.println(">>>" + catalogItems.getAttribute("value"));
        Assert.assertEquals("Apple - $2.99", catalogItems.getAttribute("value"));

        webClient.closeAllWindows();
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

        // Get the first page
        final HtmlPage page = (HtmlPage) _webClient.getPage(_url);

        // Get the form that we are dealing with and within that form,
        // find the submit button and the field that we want to change.
        final HtmlForm form = (HtmlForm) page.getForms().get(0);
        final HtmlSubmitInput allCompaniesButton = (HtmlSubmitInput)form.getHtmlElementById("doFill");
        // Now submit the form by clicking the button
        final HtmlPage resultPage = (HtmlPage)allCompaniesButton.click();

        //verify the resultPage
        String responseText = resultPage.asText();
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

        // Get the first page
        final HtmlPage page = (HtmlPage) _webClient.getPage(_url);

        // Get the form that we are dealing with and within that form,
        // find the submit button and the field that we want to change.
        final HtmlForm form = (HtmlForm) page.getForms().get(0);
        final HtmlSubmitInput allCompaniesButton = (HtmlSubmitInput)form.getHtmlElementById("doFillAll");
        // Now submit the form by clicking the button
        final HtmlPage resultPage = (HtmlPage)allCompaniesButton.click();

        //verify the resultPage
        String responseText = resultPage.asText();
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

        // Get the first page
        final HtmlPage page = (HtmlPage) _webClient.getPage(_url);

        // Get the form that we are dealing with and within that form,
        // find the submit button and the field that we want to change.
        final HtmlForm form = (HtmlForm) page.getForms().get(0);
        final HtmlSubmitInput allCompaniesButton = (HtmlSubmitInput)form.getHtmlElementById("doAddDepartment");
        // Now submit the form by clicking the button
        final HtmlPage resultPage = (HtmlPage)allCompaniesButton.click();

        //verify the resultPage
        String responseText = resultPage.asText();
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

        // Get the first page
        final HtmlPage page = (HtmlPage) _webClient.getPage(_url);

        // Get the form that we are dealing with and within that form,
        // find the submit button and the field that we want to change.
        final HtmlForm form = (HtmlForm) page.getForms().get(0);
        final HtmlSubmitInput allCompaniesButton = (HtmlSubmitInput)form.getHtmlElementById("doChangeDepartmentNames");
        // Now submit the form by clicking the button
        final HtmlPage resultPage = (HtmlPage)allCompaniesButton.click();

        //verify the resultPage
        String responseText = resultPage.asText();
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

        // Get the first page
        final HtmlPage page = (HtmlPage) _webClient.getPage(_url);

        // Get the form that we are dealing with and within that form,
        // find the submit button and the field that we want to change.
        final HtmlForm form = (HtmlForm) page.getForms().get(0);
        final HtmlSubmitInput allCompaniesButton = (HtmlSubmitInput)form.getHtmlElementById("doDeleteDepartments");
        // Now submit the form by clicking the button
        final HtmlPage resultPage = (HtmlPage)allCompaniesButton.click();

        //verify the resultPage
        String responseText = resultPage.asText();
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

                Collections.singleton(new EnvironmentVariablesNodeProperty(
                        new Entry("KEY", "value"))));
   
    WebClient webClient = new WebClient();
    HtmlPage page = webClient.getPage(hudson, "configure");
    HtmlForm form = page.getFormByName("config");
    submit(form);
   
    Assert.assertEquals(1, hudson.getGlobalNodeProperties().toList().size());
   
    EnvironmentVariablesNodeProperty prop = hudson.getGlobalNodeProperties().get(EnvironmentVariablesNodeProperty.class);
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm

  public void testFormRoundTripForSlave() throws Exception {
    setVariables(slave, new Entry("KEY", "value"));
   
    WebClient webClient = new WebClient();
    HtmlPage page = webClient.getPage(slave, "configure");
    HtmlForm form = page.getFormByName("config");
    submit(form);
   
    Assert.assertEquals(1, slave.getNodeProperties().toList().size());
   
    EnvironmentVariablesNodeProperty prop = slave.getNodeProperties().get(EnvironmentVariablesNodeProperty.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.