Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlInput


      final HtmlPage uploadPage = (HtmlPage) linkEl.click();
      if (uploadPage == null){
         fail("Could not read page");
      }
           
      final HtmlInput el1 = (HtmlInput) uploadPage.getFirstByXPath(FILE_UPLOAD_FILE);
      if (el1 == null) {
         fail("Element file upload file doesn't exist");
      } else {        
         el1.type(IMAGE_TO_UPLOAD);
      }     
     
      final HtmlInput el2 = (HtmlInput) uploadPage.getFirstByXPath(FILE_UPLOAD_UPDATE);
      final HtmlPage finishPage = (HtmlPage) el2.click();
      final HtmlElement el3 = (HtmlElement) finishPage.getFirstByXPath(FILE_UPLOAD_RESPONSE);
     
      assertFalse("Page should contain \"Successfully updated\"", el3 == null);
   }
View Full Code Here


        public RequestAssertion afterSubmittingForm(String formName,
                FormInputValue...formVals) throws Exception {
           
            HtmlForm form = ((HtmlPage)page).getFormByName(formName);
            for (FormInputValue formVal : formVals) {
                HtmlInput input = form.getInputByName(formVal.getInputName());
                formVal.handleInput(input);
            }
            HtmlSubmitInput submit = form.getInputByValue("submit");
            page = submit.click();
            return this;
View Full Code Here

    }

    @Test
    public void testRequest() throws Exception {
        HtmlPage page = requestPage();
        HtmlInput input = getInput(page);
        assertNotNull(input);
    }
View Full Code Here

    }

    @Test
    public void testRequest() throws Exception {
        HtmlPage page = requestPage();
        HtmlInput input = getInput(page);
        assertNotNull(input);
    }
View Full Code Here

    }

    @Test
    public void testRequest() throws Exception {
        HtmlPage page = requestPage();
        HtmlInput input = getInput(page);
        assertNotNull(input);
    }
View Full Code Here

        environment = null;
    }

    protected HtmlPage submitValueAndCheckMessage(String value, Matcher<String> matcher) throws Exception {
        HtmlPage page = requestPage();
        HtmlInput input = getInput(page);
        page = (HtmlPage) input.setValueAttribute(value);
        page = submit(page);
        checkMessage(page, "uiMessage", matcher);
        return page;
    }
View Full Code Here

        HtmlElement message = (HtmlElement) page.getElementById(messageId);
        assertThat(message.getTextContent(), matcher);
    }

    protected HtmlPage submit(HtmlPage page) throws IOException {
        HtmlInput input = getInput(page);
        input.fireEvent("blur");
        return page;
    }
View Full Code Here

    }

    protected HtmlInput getInput(HtmlPage page) {
        HtmlForm htmlForm = page.getFormByName("form");
        assertNotNull(htmlForm);
        HtmlInput input = htmlForm.getInputByName("form:text");
        return input;
    }
View Full Code Here

        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);
View Full Code Here

    // 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);
     
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.html.HtmlInput

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.