Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.DomText


    @Test
    public void testEdit() throws Exception {
        HtmlPage page = environment.getPage("/inplaceInputTest.jsf");
        edit(page, BASE_ID + DEFAULT, "Another Test String");
        blur(page);
        DomText text = page.getFirstByXPath("//*[@id = '" + BASE_ID + "DefaultLabel']/text()");
        assertEquals("Another Test String", text.getTextContent());
        HtmlElement span = page.getFirstByXPath("//*[@id = '" + BASE_ID + DEFAULT + "']");
        assertEquals("rf-ii rf-ii-chng", span.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));
    }
View Full Code Here


        HtmlElement cancel = page.getFirstByXPath("//*[@id = '" + withControlsComponentId + "Cancelbtn']");
        assertNotNull(cancel);
        cancel.mouseDown();

        DomText text = page.getFirstByXPath("//*[@id = '" + withControlsComponentId + "Label']/text()");
        assertNotNull(text);
        assertEquals("Edit Text", text.getTextContent());

        HtmlElement span = page.getFirstByXPath("//*[@id = '" + withControlsComponentId + "']");
        assertNotNull(span);
        assertEquals("rf-ii", span.getAttribute(HtmlConstants.CLASS_ATTRIBUTE));

        edit(page, withControlsComponentId, "Another Test String");

        HtmlElement ok = page.getFirstByXPath("//*[@id = '" + withControlsComponentId + "Okbtn']");
        assertNotNull(ok);
        ok.mouseDown();

        text = page.getFirstByXPath("//*[@id = '" + withControlsComponentId + "Label']/text()");
        assertNotNull(text);
        assertEquals("Another Test String", text.getTextContent());

        span = page.getFirstByXPath("//*[@id = '" + withControlsComponentId + "']");
        assertNotNull(span);
        String[] classAttribute = span.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).split(" ");
        assertThat(Arrays.asList(classAttribute), CoreMatchers.hasItems("rf-ii", "rf-ii-chng"));

        edit(page, withControlsComponentId, "Test String");

        blur(page);

        text = page.getFirstByXPath("//*[@id = '" + withControlsComponentId + "Label']/text()");
        assertNotNull(text);
        assertEquals("Test String", text.getTextContent());
    }
View Full Code Here

       
        String clazz = span.getAttributeValue(HTML.class_ATTRIBUTE);
        assertNotNull(clazz);
        assertTrue(clazz.contains("rich-table-sortable-header"));
       
        DomText text = (DomText) span.getFirstDomChild();
        assertNotNull(text);
       
        HtmlElement img = (HtmlElement) text.getNextDomSibling();
        assertNotNull(img);
        assertEquals(HTML.IMG_ELEMENT, img.getTagName());
        assertNull(img.getNextDomSibling());
       
        String src = img.getAttributeValue(HTML.src_ATTRIBUTE);
View Full Code Here

  assertTrue("span".equalsIgnoreCase(node.getTagName()));
 
  node = (HtmlElement) node.getLastChild();
  assertTrue("script".equalsIgnoreCase(node.getTagName()));
 
  DomText text = (DomText) node.getFirstChild();
  assertTrue(text.getData().contains("$('" + clientId + "').component"));
  assertTrue(text.getData().contains("renderLabel"));

  assertEquals(1L, progressBar.getNumber(1));
  assertEquals(new Double(1), progressBar.getNumber("1"));
  assertEquals(0, progressBar.getNumber(null));
 
View Full Code Here

    form = null;
  }

  private String getQueueScript(HtmlPage page) throws JaxenException {
    List<?> list = page.getByXPath("//head/script[@id='" + QueueScriptResourceRenderer.QUEUE_SCRIPT_ID + "']/text()");
    DomText text = (DomText) list.get(0);
    String scriptData = text.getData();
 
    return scriptData.replaceAll("^\\Qif (typeof A4J != 'undefined') { if (A4J.AJAX) { with (A4J.AJAX) {\\E|\\Q}}};\\E$", "");
  }
View Full Code Here

        assertNotNull(span1);
        scripts = span1.getHtmlElementsByTagName("script");
        int i = 0;
        for (Iterator it = scripts.iterator(); it.hasNext();) {
          HtmlScript item = (HtmlScript) it.next();
          DomText text = (DomText) item.getFirstChild();
         
          assertNotNull(text);
          assertTrue(text.asText().contains("A4J.AJAX.Push"));
         
          i++;
        }
        assertEquals(1, i);
       
        HtmlElement span2 = page.getHtmlElementById(push2.getClientId(facesContext));
        assertNotNull(span2);
        scripts = span2.getHtmlElementsByTagName("script");
        i = 0;
        for (Iterator it = scripts.iterator(); it.hasNext();) {
          HtmlScript item = (HtmlScript) it.next();
          DomText text = (DomText) item.getFirstChild();
         
          assertNotNull(text);
          assertTrue(text.asText().contains("A4J.AJAX.StopPush"));
         
          i++;
        }
        assertEquals(1, i);
  }
View Full Code Here

        copy(page, child, childXml);
    }

    private static DomNode createFrom(final SgmlPage page, final Node source) {
        if (source.getNodeType() == Node.TEXT_NODE) {
            return new DomText(page, source.getNodeValue());
        }
        final String ns = source.getNamespaceURI();
        String localName = source.getLocalName();
        if (HTMLParser.XHTML_NAMESPACE.equals(ns)) {
            final IElementFactory factory = HTMLParser.getFactory(localName);
View Full Code Here

                    dest.appendChild(childXml);
                    copy(page, child, childXml);
                    break;

                case Node.TEXT_NODE:
                    dest.appendChild(new DomText(page, child.getNodeValue()));
                    break;

                case Node.CDATA_SECTION_NODE:
                    dest.appendChild(new DomCDataSection(page, child.getNodeValue()));
                    break;
View Full Code Here

     * Split a Text node in two.
     * @param offset the character position at which to split the Text node
     * @return the Text node that was split from this node
     */
    public Object jsxFunction_splitText(final int offset) {
        final DomText domText = (DomText) getDomNodeOrDie();
        return getScriptableFor(domText.splitText(offset));
    }
View Full Code Here

     * @return the new text node or NOT_FOUND if there is an error
     */
    public Object jsxFunction_createTextNode(final String newData) {
        Object result = NOT_FOUND;
        try {
            final DomNode domNode = new DomText(this.<DomNode>getDomNodeOrDie().getPage(), newData);
            final Object jsElement = getScriptableFor(domNode);

            if (jsElement == NOT_FOUND) {
                LOG.debug("createTextNode(" + newData
                    + ") cannot return a result as there isn't a JavaScript object for the DOM node "
                    + domNode.getClass().getName());
            }
            else {
                result = jsElement;
            }
        }
View Full Code Here

TOP

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

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.