Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlForm


    /**
     * <p>Validate pristine instance of the test page.</p>
     */
    public void testPristine() throws Exception {

        HtmlForm form = null;
        HtmlElement text = null;
        HtmlSubmitInput submit = null;

        // setUp() should have put us on the page
        assertEquals("View Controller Test", title());
View Full Code Here


    /**
     * <p>Validate pristine instance of the "Token" test page.</p>
     */
    public void testPristine() throws Exception {

        HtmlForm form = null;
        HtmlElement message = null;
        HtmlElement messages = null;
        HtmlHiddenInput token = null;
        HtmlSubmitInput submit = null;
        HtmlTextInput value = null;
View Full Code Here

    @Test
    public void logIn() throws FailingHttpStatusCodeException, MalformedURLException, IOException, InterruptedException {

        HtmlPage page = webClient.getPage(BASEURI + "login.jsp");
        HtmlForm form = page.getFormByName("loginform");
        form.<HtmlInput>getInputByName("username").setValueAttribute("root");
        form.<HtmlInput>getInputByName("password").setValueAttribute("secret");
        page = form.<HtmlInput>getInputByName("submit").click();
        // This'll throw an expection if not logged in
        page.getAnchorByHref("/logout.jsp");
    }
View Full Code Here

    }

    @Test
    public void logInAndRememberMe() throws Exception {
        HtmlPage page = webClient.getPage(BASEURI + "login.jsp");
        HtmlForm form = page.getFormByName("loginform");
        form.<HtmlInput>getInputByName("username").setValueAttribute("root");
        form.<HtmlInput>getInputByName("password").setValueAttribute("secret");
        HtmlCheckBoxInput checkbox = form.getInputByName("rememberMe");
        checkbox.setChecked(true);
        page = form.<HtmlInput>getInputByName("submit").click();
        server.stop();
        server.start();
        page = webClient.getPage(BASEURI);
        // page.getAnchorByHref("/logout.jsp");
        WebAssert.assertLinkPresentWithText(page, "Log out");
View Full Code Here

    public void testConversationDialog() throws Exception
    {
        HtmlPage page = webClient.getPage(BASE_URL + "conversation/conversation1.xhtml");

        // page 1
        HtmlForm form = page.getFormByName("conversation1");
        form.getInputByName("conversation1:value1").setValueAttribute("1");
        page = form.getInputByName("conversation1:nextPage").click();

        // page 2
        form = page.getFormByName("conversation2");
        form.getInputByName("conversation2:value2").setValueAttribute("2");
        page = form.getInputByName("conversation2:nextPage").click();

        // page 3
        form = page.getFormByName("conversation3");
        form.getInputByName("conversation3:value3").setValueAttribute("3");
        page = form.getInputByName("conversation3:submit").click();

        // result page
        Assert.assertEquals("1", page.getElementById("value1").getTextContent());
        Assert.assertEquals("2", page.getElementById("value2").getTextContent());
        Assert.assertEquals("3", page.getElementById("value3").getTextContent());

        // GET request
        page = page.getElementById("refresh").click();

        Assert.assertEquals("1", page.getElementById("value1").getTextContent());
        Assert.assertEquals("2", page.getElementById("value2").getTextContent());
        Assert.assertEquals("3", page.getElementById("value3").getTextContent());

        // GET request to page 3
        page = page.getElementById("back").click();

        // POST request to page 2
        page = page.getElementById("conversation3:back").click();

        // page 2
        form = page.getFormByName("conversation2");
        form.getInputByName("conversation2:value2").setValueAttribute("new2");
        page = form.getInputByName("conversation2:nextPage").click();

        // page 3
        form = page.getFormByName("conversation3");
        form.getInputByName("conversation3:value3").setValueAttribute("new3");
        page = form.getInputByName("conversation3:submit").click();

        // result page
        Assert.assertEquals("1", page.getElementById("value1").getTextContent());
        Assert.assertEquals("new2", page.getElementById("value2").getTextContent());
        Assert.assertEquals("new3", page.getElementById("value3").getTextContent());

        // close conversation
        form = page.getFormByName("form");
        page = form.getInputByName("form:closeConversation").click();

        // values must be empty
        Assert.assertEquals("", page.getElementById("value1").getTextContent());
        Assert.assertEquals("", page.getElementById("value2").getTextContent());
        Assert.assertEquals("", page.getElementById("value3").getTextContent());
View Full Code Here

    public void testConversationDialogRestart() throws Exception
    {
        HtmlPage page = webClient.getPage(BASE_URL + "conversation/conversation1.xhtml");

        // page 1
        HtmlForm form = page.getFormByName("conversation1");
        form.getInputByName("conversation1:value1").setValueAttribute("1");
        page = form.getInputByName("conversation1:nextPage").click();

        // page 2
        form = page.getFormByName("conversation2");
        form.getInputByName("conversation2:value2").setValueAttribute("2");
        page = form.getInputByName("conversation2:nextPage").click();

        // page 3
        form = page.getFormByName("conversation3");
        form.getInputByName("conversation3:value3").setValueAttribute("3");
        page = form.getInputByName("conversation3:submit").click();

        // result page
        Assert.assertEquals("1", page.getElementById("value1").getTextContent());
        Assert.assertEquals("2", page.getElementById("value2").getTextContent());
        Assert.assertEquals("3", page.getElementById("value3").getTextContent());

        // restart conversation
        form = page.getFormByName("form");
        page = form.getInputByName("form:restartConversation").click();

        // values must be empty
        Assert.assertEquals("", page.getElementById("value1").getTextContent());
        Assert.assertEquals("", page.getElementById("value2").getTextContent());
        Assert.assertEquals("", page.getElementById("value3").getTextContent());
View Full Code Here

      queryPage = (HtmlPage) wb.getPage(queryUrl);
     //queryPage = (HtmlPage) wb.getPage(wb.getCurrentWindow(), wrs);
     //System.out.println(queryPage.getPageEncoding());
    
     //Estado
     HtmlForm form = queryPage.getFormByName("AG");
     HtmlSelect select = form.getSelectByName("S7_");
     List<HtmlOption> listEstadoOptions = select.getOptions();
     for(int i=1; i< listEstadoOptions.size(); i++){
       select.setSelectedAttribute(Integer.toString(i), true);
       System.out.println("numEstado"+i);
       System.out.println("estado"+listEstadoOptions.get(i).asText());
          //Area (Somente as de engenharia: 20 a 23)
       queryPage = (HtmlPage) wb.getPage(queryUrl);
       form = queryPage.getFormByName("AG");
       select = form.getSelectByName("S11_");
       List<HtmlOption> listAreaOptions = select.getOptions();
       for(int j=20; j< 24; j++){//So engenharia
         select.setSelectedAttribute(Integer.toString(j), true);
         System.out.println("numArea"+j);
         System.out.println("area"+listAreaOptions.get(j).asText());
         //IEF
         queryPage = (HtmlPage) wb.getPage(queryUrl);
         form = queryPage.getFormByName("AG");
         select = form.getSelectByName("S9_");
         List<HtmlOption> listIefOptions = select.getOptions();
         for(int k=1; k< listIefOptions.size(); k++){
           select.setSelectedAttribute(Integer.toString(k), true);
           System.out.println("numIef"+k);
           System.out.println("ief"+listIefOptions.get(k).asText());
           //Programa
           queryPage = (HtmlPage) wb.getPage(queryUrl);
           form = queryPage.getFormByName("AG");
           select = form.getSelectByName("S13_");
           List<HtmlOption> listProgramaOptions = select.getOptions();
           for(int m=1; m< listProgramaOptions.size(); m++){
             System.out.println("m"+m);
             select.setSelectedAttribute(Integer.toString(m), true);
             System.out.println("numPrograma"+m);
             System.out.println("programa"+listProgramaOptions.get(m).asText());
             corrente = new Programa();
             corrente.setNumEstado(i);
             String estado = listEstadoOptions.get(i).asText();
             corrente.setEstado(estado);
             corrente.setNumAreaAvaliacao(j);
             String areaAvaliacao = listAreaOptions.get(j).asText();
             corrente.setAreaAvaliacao(areaAvaliacao);
             corrente.setNumIef(k);
             String ief = listIefOptions.get(k).asText();
             corrente.setIef(ief);
             String programa = listProgramaOptions.get(m).asText();
             corrente.setNumPrograma(m);
             corrente.setPrograma(programa);
             listaDeProgramas.add(corrente);
             System.out.println(i+estado+" "+j+areaAvaliacao+" "+k+ief+" "+m+programa);
             programaDAO.insert(corrente);
            
             //queryPage = (HtmlPage) wb.getPage(wb.getCurrentWindow(), wrs);
             //form = queryPage.getFormByName("AG");
             //select = form.getSelectByName("S13_");
             //listProgramaOptions = select.getOptions();
           }
           //Ief
           queryPage = (HtmlPage) wb.getPage(queryUrl)
           form = queryPage.getFormByName("AG");
           select = form.getSelectByName("S9_");
           listIefOptions = select.getOptions();
         }
         //Area
         queryPage = (HtmlPage) wb.getPage(queryUrl);
         form = queryPage.getFormByName("AG");
         select = form.getSelectByName("S11_");
         listAreaOptions = select.getOptions();
       }
       //Estado
       queryPage = (HtmlPage) wb.getPage(queryUrl)
       form = queryPage.getFormByName("AG");
       select = form.getSelectByName("S7_");
       listEstadoOptions = select.getOptions();
     }
    
    } 
View Full Code Here

   WebClient wb = new WebClient ()
   System.out.println("Aqui2");
   HtmlPage queryPage = (HtmlPage) wb.getPage(queryUrl)
   System.out.println("Aqui0");
   //Estado
   HtmlForm form = queryPage.getFormByName("AG");
   HtmlSelect Select = form.getSelectByName("S7_");
   Select.setSelectedAttribute("6", true);
   List<HtmlOption> list = Select.getOptions();
   /*for(HtmlOption ho: list){
     System.out.println(ho.asText());
   }
   System.out.println(queryPage.asText());
   */
   System.out.println("Aqui1");
   //IEF
   queryPage = (HtmlPage) wb.getPage(queryUrl);
   form = queryPage.getFormByName("AG");
   Select = form.getSelectByName("S9_");
   Select.setSelectedAttribute("1", true);
   list = Select.getOptions();
   /*for(HtmlOption ho: list){
     System.out.println(ho.asText());
   }
   System.out.println(queryPage.asText());
   */
  
   //Area
   queryPage = (HtmlPage) wb.getPage(queryUrl);
   form = queryPage.getFormByName("AG");
   Select = form.getSelectByName("S11_");
   Select.setSelectedAttribute("10", true);
   list = Select.getOptions();
   /*for(HtmlOption ho: list){
     System.out.println(ho.asText());
   }
   System.out.println(queryPage.asText());
   */
  
//Programa
   queryPage = (HtmlPage) wb.getPage(queryUrl);
   form = queryPage.getFormByName("AG");
   Select = form.getSelectByName("S13_");
   Select.setSelectedAttribute("1", true);
   list = Select.getOptions();
   /*for(HtmlOption ho: list){
     System.out.println(ho.asText());
   }*/
   System.out.println(queryPage.asText());
  
   /* 
   //Professores
   List<HtmlRadioButtonInput> radioButtonList = form.getRadioButtonsByName("S15_");
   for(HtmlRadioButtonInput hr: radioButtonList){
     System.out.println(hr);
   }
   */
   HtmlInput hi= form.getInputByName("S19_");
   System.out.println(hi);
   Set<Cookie> cookies = wb.getCookieManager().getCookies();
   try{
  
   }
View Full Code Here

        //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

     */
    protected HtmlForm form(String id) throws Exception {

        Iterator forms = page.getAllForms().iterator();
        while (forms.hasNext()) {
            HtmlForm form = (HtmlForm) forms.next();
            if (id.equals(form.getAttributeValue("id"))) {
                return (form);
            }
        }
        return (null);

View Full Code Here

TOP

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

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.