Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlHiddenInput


    public void testPristine() throws Exception {

        HtmlForm form = null;
        HtmlElement message = null;
        HtmlElement messages = null;
        HtmlHiddenInput token = null;
        HtmlSubmitInput submit = null;
        HtmlTextInput value = null;

        // setUp() should have put us on the page
        assertEquals("Shale Token Test", title());
        form = (HtmlForm) element("form");
        assertNotNull(form);
        messages = element("form:messages");
        // MyFaces 1.1 and the JSF RI 1.1 are inconsistent about whether the
        // "messages" element is actually created when there are no messages
//        assertNull(messages);
        value = (HtmlTextInput) element("form:value");
        assertNotNull(value);
        assertEquals("", value.getValueAttribute());
        message = element("form:valueMessage");
        assertNull(message);
        token = (HtmlHiddenInput) element("form:token");
        assertNotNull(token);
        assertNotNull(token.getValueAttribute());
        message = element("form:tokenMessage");
        assertNull(message);
        submit = (HtmlSubmitInput) element("form:submit");
        assertNotNull(submit);
View Full Code Here


        List list = form.getHtmlElementsByAttribute
            ("input", "name",
             "org_apache_struts_faces_renderer_CommandLinkRenderer");
        assertNotNull(list);
        assertEquals(1, list.size());
        HtmlHiddenInput hidden = (HtmlHiddenInput) list.get(0);
        assertEquals("hidden", hidden.getTypeAttribute());
        assertEquals("", hidden.getValueAttribute());

    }
View Full Code Here

     
      // Find the hidden input control
      e = client.getElement(controlId+"value");
      assertNotNull("Control not found: "+controlId+"value",e);
      assertTrue("Control not expected type (HtmlHiddenInput): "+e.getClass(),e instanceof HtmlHiddenInput);
      HtmlHiddenInput hiddenInput = (HtmlHiddenInput)e;
     
      // Make sure the hidden value is set
      String hiddenValue = hiddenInput.getValueAttribute();
      assertEquals("Hidden control value is not set as expected",value,hiddenValue);
     
   }
View Full Code Here

   {
      // Find the hidden input control
      Element e = client.getElement(componentID+"value");
      assertNotNull("Control not found: "+componentID+"value",e);
      assertTrue("Control not expected type (HtmlHiddenInput): "+e.getClass(),e instanceof HtmlHiddenInput);
      HtmlHiddenInput hiddenInput = (HtmlHiddenInput)e;
     
      // Make sure the hidden value is set
      String hiddenValue = hiddenInput.getValueAttribute();
      assertEquals("Hidden control value is not set as expected",value,hiddenValue);
   }
View Full Code Here

        List list = form.getHtmlElementsByAttribute
            ("input", "name",
             "org_apache_struts_faces_renderer_CommandLinkRenderer");
        assertNotNull(list);
        assertEquals(1, list.size());
        HtmlHiddenInput hidden = (HtmlHiddenInput) list.get(0);
        assertEquals("hidden", hidden.getTypeAttribute());
        assertEquals("", hidden.getValueAttribute());

    }
View Full Code Here

    public void testOnClickReturnTrue() throws Exception {
        HtmlPage page = getPage("/faces/jsp/commandLinkOnClickTrue.jsp");

        HtmlForm form = getFormById(page, "form");
        assertNotNull("form exists", form);
        HtmlHiddenInput hidden = null;
        try {
            hidden = (HtmlHiddenInput)form.getInputByName("form:j_idcl");
        } catch (ElementNotFoundException e) {
            assertTrue(false);
        }
        // This initial value was set by an "onLoad" javascript function in the jsp.
        assertTrue(hidden.getValueAttribute().equals("Goodbye"));

        // click the link..
        HtmlAnchor submit = (HtmlAnchor)
            page.getFirstAnchorByText("submit");
            assertTrue(submit.getOnClickAttribute().equals("var a=function(){setValue('form');};var b=function(){clearFormHiddenParams_form('form');document.forms['form']['form:j_idcl'].value='form:submit'; document.forms['form'].submit(); return false;};return (a()==false) ? false : b();"));
        try {
            page = (HtmlPage) submit.click();
  } catch (Exception e) {
      e.printStackTrace();
      assertTrue(false);
        }
        // The value of this field was set by the user provided "onclick" javascript
        // function.
        HtmlTextInput input = (HtmlTextInput)form.getInputByName("form:init");
        assertTrue(input.getValueAttribute().equals("Hello"));

        // The value of this field was changed by the internal Faces javascript function
        // created by CommandLinkRenderer..
        try {
            hidden = (HtmlHiddenInput)form.getInputByName("form:j_idcl");
        } catch (ElementNotFoundException e) {
            assertTrue(false);
        }
        assertTrue(hidden.getValueAttribute().equals("form:submit"));
    }
View Full Code Here

    public void testOnClickReturnFalse() throws Exception {
        HtmlPage page = getPage("/faces/jsp/commandLinkOnClickFalse.jsp");
                                                                                                           
        HtmlForm form = getFormById(page, "form");
        assertNotNull("form exists", form);
        HtmlHiddenInput hidden = null;
        try {
            hidden = (HtmlHiddenInput)form.getInputByName("form:j_idcl");
        } catch (ElementNotFoundException e) {
            assertTrue(false);
        }
        // This initial value was set by an "onLoad" javascript function in the jsp.
        assertTrue(hidden.getValueAttribute().equals("Goodbye"));
                                                                                                           
        // click the link..
        HtmlAnchor submit = (HtmlAnchor)
            page.getFirstAnchorByText("submit");
            assertTrue(submit.getOnClickAttribute().equals("var a=function(){setValue('form'); return false;};var b=function(){clearFormHiddenParams_form('form');document.forms['form']['form:j_idcl'].value='form:submit'; document.forms['form'].submit(); return false;};return (a()==false) ? false : b();"));
        try {
            page = (HtmlPage) submit.click();
        } catch (Exception e) {
            e.printStackTrace();
            assertTrue(false);
        }
        HtmlTextInput input = (HtmlTextInput)form.getInputByName("form:init");
        assertTrue(input.getValueAttribute().equals("Hello"));
                                                                                                           
        // The value of this field remains unchanged from the initial value.
        try {
            hidden = (HtmlHiddenInput)form.getInputByName("form:j_idcl");
        } catch (ElementNotFoundException e) {
            assertTrue(false);
        }
        assertTrue(hidden.getValueAttribute().equals("Goodbye"));
    }
View Full Code Here

    // HTML_BASIC is set.  Also assert that the hidden field was not written;
    public void testNoRenderKitId() throws Exception {
        HtmlPage page = getPage("/faces/renderkit06.jsp");
        HtmlForm form = getFormById(page, "form");
        assertNotNull("form exists", form);
        HtmlHiddenInput hidden = null;
        boolean exceptionThrown = false;
        try {
            hidden = (HtmlHiddenInput)form.getInputByName("javax.faces.RenderKitId");
        } catch (ElementNotFoundException e) {
            exceptionThrown = true;
View Full Code Here

        // Load a page with renderKitId="CUSTOM";
        // Assert hidden field is not written because renderKitId == defaultRenderKitId;
        page = getPage("/faces/renderkit06.jsp");
        HtmlForm form = getFormById(page, "form");
        assertNotNull("form exists", form);
        HtmlHiddenInput hidden = null;
        boolean exceptionThrown = false;
        try {
            hidden = (HtmlHiddenInput)form.getInputByName("javax.faces.RenderKitId");
        } catch (ElementNotFoundException e) {
            exceptionThrown = true;
View Full Code Here

    public void testMultiForm() throws Exception {
        HtmlForm form1, form2;
        HtmlAnchor link1, link2, link3;
        HtmlTextInput input;
        HtmlPage page, page1;
        HtmlHiddenInput hidden1, hidden2;

        page = getPage("/faces/taglib/commandLink_multiform_test.jsp");
        // press all command links..
        List forms = page.getForms();
        form1 = (HtmlForm)forms.get(0);
        form2 = (HtmlForm)forms.get(1);
       
        // links within the first form
        hidden1 = (HtmlHiddenInput)form1.getInputByName("form01:j_idcl");
        assertNotNull(hidden1);
        hidden1.setValueAttribute("form01:Link1");
        page1 = (HtmlPage)form1.submit();
        assertTrue(-1 != page1.asText().indexOf("Thank you"));
        hidden1.setValueAttribute("form01:Link2");
        page1 = (HtmlPage)form1.submit();
        assertTrue(-1 != page1.asText().indexOf("Thank you"));

        // links within second form
        hidden2 = (HtmlHiddenInput)form2.getInputByName("form02:j_idcl");
View Full Code Here

TOP

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

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.