Examples of HtmlSpan


Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

       
        HtmlPage page = getPage("/faces/forEach04.jsp");
        List<HtmlSpan> spans = new ArrayList<HtmlSpan>(2);
        getAllElementsOfGivenClass(page, spans, HtmlSpan.class);
        assertTrue(spans.size() == 2);
        HtmlSpan span = spans.get(0);
        assertTrue("j_id_id16:idfrag1:frag1".equals(span.getIdAttribute()));
        span = spans.get(1);
        assertTrue("j_id_id16:idfrag2:frag2".equals(span.getIdAttribute()));

        // submit the form to ensure no duplicate ID exceptions are
        // raised during post-back
        List<HtmlSubmitInput> buttons = new ArrayList<HtmlSubmitInput>(1);
        buttons = getAllElementsOfGivenClass(page, buttons, HtmlSubmitInput.class);
        assertTrue(buttons.size() == 1);
        HtmlSubmitInput submit = buttons.get(0);
        page = (HtmlPage) submit.click();

        // validate the IDs are as expected after post-back
        spans = new ArrayList<HtmlSpan>(2);
        getAllElementsOfGivenClass(page, spans, HtmlSpan.class);
        assertTrue(spans.size() == 2);
        span = spans.get(0);
        assertTrue("j_id_id16:idfrag1:frag1".equals(span.getIdAttribute()));
        span = spans.get(1);
        assertTrue("j_id_id16:idfrag2:frag2".equals(span.getIdAttribute()));

    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

  boolean
      hasMessageContent = false, // do we have the h:message
               // content we're looking for
      hasMessagesContent = false; // do we have the h:messages
          // content we're looking for.
  HtmlSpan span = null;
        HtmlUnorderedList ulist = null;

  for (int i = 0; i < list.size(); i++) {
      span = (HtmlSpan) list.get(i);
      if (-1 != span.asXml().indexOf("dir=\"RTL\"")
                && span.asXml().indexOf("lang=\"de\"") != -1) {
                hasMessageContent = true;
            }
        }
        list = getAllElementsOfGivenClass(page, null, HtmlUnorderedList.class);
        for (int i = 0; i < list.size(); i++) {
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

    private Map mapMessagesById(HtmlElement docElem) {
        Map elems = new TreeMap();
        List tags = docElem.getHtmlElementsByTagName("span");
        for (Iterator tagIt = tags.iterator(); tagIt.hasNext();) {
            HtmlSpan tag = (HtmlSpan) tagIt.next();
            if ("message".equals(tag.getClassAttribute())) {
                String text = tag.asText();
                assertNotSame(
                        "expect validation message to start with component id",
                        -1, text.indexOf(": "));
                String id = text.substring(0, text.indexOf(": ")).trim();
                assertFalse("Duplicate message for input " + id, elems
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

              ": This link is disabled as it is not nested within a JSF form.";
        HtmlPage page = getPage("/faces/standard/clinknoform.jsp");
        List list = getAllElementsOfGivenClass(page, null,
                                               HtmlSpan.class);
       
        HtmlSpan p = (HtmlSpan) list.get(0);
        assertEquals("Link1" + noFormString, p.asText());
        p = (HtmlSpan) list.get(1);
        assertEquals("Link2" + noFormString, p.asText());
        p = (HtmlSpan) list.get(2);
        assertEquals("Click me once and click me twice" +
                     noFormString, p.asText());       
    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

        .getHtmlElementById(calendar.getClientId(facesContext)
            + "InputDate");
    HtmlButton htmlCalendarButton = (HtmlButton) page
        .getHtmlElementById(calendar.getClientId(facesContext)
            + "PopupButton");
    HtmlSpan htmlCalendarSpan = (HtmlSpan) page.getHtmlElementById(calendar
        .getClientId(facesContext)
        + "Popup");
    assertNotNull(htmlCalendarInput);
    assertNotNull(htmlCalendarButton);
    assertNotNull(htmlCalendarSpan);
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

     * <p>Verify the content of a pristine page returned when executing this
     * view for the first time.</p>
     */
    public void testPristine() throws Exception {

        HtmlSpan span = null;

        HtmlElement html = (HtmlElement) page;
        assertEquals("html", html.getTagName());
        assertEquals("http://www.w3.org/1999/xhtml", html.getAttributeValue("xmlns"));

        assertEquals("logon", title());

        HtmlForm form = (HtmlForm) element("form");
        assertNotNull(form);
        assertEquals("", form.getAcceptAttribute());
        assertEquals("", form.getAcceptCharsetAttribute());
        String url = this.url.toString();
        url = url.substring(0, url.length() - 1);
        url = url.substring(url.lastIndexOf('/'));
        String action = form.getActionAttribute();
        int semicolon = action.indexOf(';');
        if (semicolon >= 0) {
            action = action.substring(0, semicolon);
        }
        assertEquals(url + "/logon.faces", action);
        assertEquals("", form.getEnctypeAttribute());
        assertEquals("post", form.getMethodAttribute());
        assertEquals("logonForm", form.getNameAttribute());
        assertEquals("", form.getOnResetAttribute());
        assertEquals("", form.getOnSubmitAttribute());
        assertEquals("", form.getTargetAttribute());

        span = (HtmlSpan) element("form:usernamePrompt");
        assertNotNull(span);
        assertEquals("Username:", span.asText());

        HtmlTextInput username = (HtmlTextInput) element("form:username");
        assertNotNull(username);
        assertEquals("", username.getLangAttribute());
        assertEquals("form:username", username.getNameAttribute());
        assertEquals("", username.getOnClickAttribute());
        assertEquals("", username.getOnDblClickAttribute());
        assertEquals("", username.getOnKeyDownAttribute());
        assertEquals("", username.getOnKeyPressAttribute());
        assertEquals("", username.getOnKeyUpAttribute());
        assertEquals("", username.getOnMouseDownAttribute());
        assertEquals("", username.getOnMouseMoveAttribute());
        assertEquals("", username.getOnMouseOutAttribute());
        assertEquals("", username.getOnMouseOverAttribute());
        assertEquals("", username.getOnMouseUpAttribute());
        assertEquals("text", username.getTypeAttribute());
        assertEquals("", username.getValueAttribute());

        span = (HtmlSpan) element("form:passwordPrompt");
        assertNotNull(span);
        assertEquals("Password:", span.asText());

        HtmlPasswordInput password = (HtmlPasswordInput)
            element("form:password");
        assertNotNull(password);
        assertEquals("", password.getLangAttribute());
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

    /**
     * <p>Submit known-bad mismatch and verify the correct response.</p>
     */
    public void testMismatch() throws Exception {

        HtmlSpan span = null;
        HtmlTextInput username = (HtmlTextInput) element("form:username");
        HtmlPasswordInput password = (HtmlPasswordInput)
            element("form:password");
        HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");

        username.setValueAttribute("baduser");
        password.setValueAttribute("badpass");
        submit(submit);

        assertEquals("logon", title());

        span = (HtmlSpan) element("globalErrors");
        assertNotNull(span);
        assertEquals("[EH][EP]Invalid username/password combination[ES][EF]",
                     span.asText());

        username = (HtmlTextInput) element("form:username");
        assertNotNull(username);
        assertEquals("baduser", username.getValueAttribute());

        span = (HtmlSpan) element("form:usernameErrors");
        assertNotNull(span);
        assertEquals("", span.asText());

        password = (HtmlPasswordInput) element("form:password");
        assertNotNull(password);
        assertEquals("", password.getValueAttribute());

        span = (HtmlSpan) element("form:passwordErrors");
        assertNotNull(span);
        assertEquals("", span.asText());

    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

     * <p>Verify the content of a pristine page returned when executing this
     * view for the first time.</p>
     */
    public void testPristine() throws Exception {

        HtmlSpan span = null;
        assertEquals("context", title());

        // Validate FacesContext Values

        span = (HtmlSpan) element("form:renderKitIdFC");
        assertEquals("HTML_BASIC", span.asText());

        span = (HtmlSpan) element("form:viewIdFC");
        assertEquals("/context.jsp", span.asText());

        // Validate ExternalContext Values

        span = (HtmlSpan) element("form:authTypeEC");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:remoteUserEC");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:requestContextPathEC");
        assertEquals("/struts-faces-systest1", span.asText()); // FIXME - Ant property?


        span = (HtmlSpan) element("form:requestLocaleEC");
        String formRequestLocaleEC = span.asText(); // FIXME - validate this

        span = (HtmlSpan) element("form:requestPathInfoEC");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:requestServletPathEC");
        assertEquals("/context.jsp", span.asText());

        // Validate HttpServletRequest Values

        span = (HtmlSpan) element("form:authTypeRQ");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:contextPathRQ");
        assertEquals("/struts-faces-systest1", span.asText()); // FIXME - Ant property?

        span = (HtmlSpan) element("form:localeRQ");
        assertEquals(formRequestLocaleEC, span.asText());

        span = (HtmlSpan) element("form:pathInfoRQ");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:remoteUserRQ");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:servletPathRQ");
        assertEquals("/context.jsp", span.asText());

        // Validate ServletContext Values

        span = (HtmlSpan) element("form:majorVersionSC");
        assertEquals("2", span.asText());

        span = (HtmlSpan) element("form:minorVersionSC");
        assertTrue("3".equals(span.asText()) || "4".equals(span.asText()));

    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

    /**
     * <p>Submit the initial form and validate the resulting values.</p>
     */
    public void testSubmit() throws Exception {

        HtmlSpan span = null;
        HtmlSpan spanCA = null;
        HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");
        submit(submit);
        assertEquals("context1", title());

        // Validate FacesContext Values

        span = (HtmlSpan) element("form:renderKitIdFC");
        assertEquals("HTML_BASIC", span.asText());

        span = (HtmlSpan) element("form:viewIdFC");
        assertEquals("/context1.jsp", span.asText());

        // Validate ExternalContext Values

        span = (HtmlSpan) element("form:authTypeEC");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:remoteUserEC");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:requestContextPathEC");
        assertEquals("/struts-faces-systest1", span.asText()); // FIXME - Ant property?

        span = (HtmlSpan) element("form:requestLocaleEC");
        String formRequestLocaleEC = span.asText(); // FIXME - validate this

        span = (HtmlSpan) element("form:requestPathInfoEC");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:requestServletPathEC");
        assertEquals("/context1.jsp", span.asText());

        // Validate HttpServletRequest Values

        span = (HtmlSpan) element("form:authTypeRQ");
        assertEquals("", span.asText());

        span = (HtmlSpan) element("form:contextPathRQ");
        assertEquals("/struts-faces-systest1", span.asText()); // FIXME - Ant property?
        spanCA = (HtmlSpan) element("form:contextPathCA");
        assertEquals(span.asText(), spanCA.asText());

        span = (HtmlSpan) element("form:localeRQ");
        assertEquals(formRequestLocaleEC, span.asText());
        spanCA = (HtmlSpan) element("form:localeCA");
        assertEquals(span.asText(), spanCA.asText());

        span = (HtmlSpan) element("form:pathInfoRQ");
        assertEquals("", span.asText());
        spanCA = (HtmlSpan) element("form:pathInfoCA");
        assertEquals(span.asText(), spanCA.asText());

        span = (HtmlSpan) element("form:remoteUserRQ");
        assertEquals("", span.asText());
        spanCA = (HtmlSpan) element("form:remoteUserCA");
        assertEquals(span.asText(), spanCA.asText());

        span = (HtmlSpan) element("form:servletPathRQ");
        assertEquals("/context1.jsp", span.asText());
        spanCA = (HtmlSpan) element("form:servletPathCA");
        assertEquals("/context.faces", spanCA.asText());

        // Validate ServletContext Values

        span = (HtmlSpan) element("form:majorVersionSC");
        assertEquals("2", span.asText());
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.html.HtmlSpan

     * <p>Verify that the loadMessages tag properly exposes a Struts
     * MessageResources instance as a Map.</p>
     */
    public void testLoadMessages() throws Exception {

        HtmlSpan span = null;

        span = (HtmlSpan) element("lookup-simple");
        assertNotNull(span);
        assertEquals("Resource Simple Text", span.asText());

        span = (HtmlSpan) element("lookup-filtered");
        assertNotNull(span);
        assertEquals("Resource <b>Filtered</b> Text", span.asText());

        span = (HtmlSpan) element("lookup-unfiltered");
        assertNotNull(span);
        assertEquals("Resource Unfiltered Text", span.asText());

    }
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.