Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlElement


        // dataScroller inside dataTable 'footer' facet
        String secondScrollerId = "richTable:scroller2";

        for (int i = 2; i <= 5; i++) {
            HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
            currentDigital1.click();

            currentDigital1 = getDigitalButton(page, firstScrollerId, i);
            assertEquals("span", currentDigital1.getNodeName());
            assertEquals("rf-ds-nmb-btn rf-ds-act", currentDigital1.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

            // if scroller inside dataTable has switched
            HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
            assertEquals("span", currentDigital2.getNodeName());
            assertEquals("rf-ds-nmb-btn rf-ds-act", currentDigital2.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

            // check if page has switched
            assertEquals(i + " page content", getCurrentPageContent(page, i));
        }

        checkLastPageButtons(page, firstScrollerId, secondScrollerId);

        // scroll back
        for (int i = 4; i >= 1; i--) {
            HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
            currentDigital1.click();

            currentDigital1 = getDigitalButton(page, firstScrollerId, i);
            assertEquals("span", currentDigital1.getNodeName());
            assertEquals("rf-ds-nmb-btn rf-ds-act", currentDigital1.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

            // if scroller inside dataTable has switched
            HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
            assertEquals("span", currentDigital2.getNodeName());
            assertEquals("rf-ds-nmb-btn rf-ds-act", currentDigital2.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

            // check if page has switched
            assertEquals(i + " page content", getCurrentPageContent(page, i));
        }
View Full Code Here


        // dataScroller inside dataTable 'footer' facet
        String secondScrollerId = "richTable:scroller2";

        for (int i = 2; i <= 5; i++) {
            HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
            currentDigital2.click();

            currentDigital2 = getDigitalButton(page, secondScrollerId, i);
            assertEquals("span", currentDigital2.getNodeName());
            assertEquals("rf-ds-nmb-btn rf-ds-act", currentDigital2.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

            // if scroller outside dataTable has switched
            HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
            assertEquals("span", currentDigital1.getNodeName());
            assertEquals("rf-ds-nmb-btn rf-ds-act", currentDigital1.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

            // check if page has switched
            assertEquals(i + " page content", getCurrentPageContent(page, i));
        }

        checkLastPageButtons(page, firstScrollerId, secondScrollerId);

        // scroll back
        for (int i = 4; i >= 1; i--) {
            HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
            currentDigital2.click();

            currentDigital2 = getDigitalButton(page, secondScrollerId, i);
            assertEquals("span", currentDigital2.getNodeName());
            assertEquals("rf-ds-nmb-btn rf-ds-act", currentDigital2.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

            // if scroller inside dataTable has switched
            HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
            assertEquals("span", currentDigital1.getNodeName());
            assertEquals("rf-ds-nmb-btn rf-ds-act", currentDigital1.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

            // check if page has switched
            assertEquals(i + " page content", getCurrentPageContent(page, i));
        }
View Full Code Here

        environment.release();
        environment = null;
    }

    private void checkFirstPageButtons(HtmlPage page, String firstScrollerId, String secondScrollerId) throws Exception {
        HtmlElement fastForward = getFastForwardButton(page, firstScrollerId);
        HtmlElement last = getLastButton(page, firstScrollerId);
        HtmlElement next = getNextButton(page, firstScrollerId);

        // check right buttons
        assertEquals("a", fastForward.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastfwd", fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("a", last.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-last", last.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("a", next.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-next", next.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        fastForward = getFastForwardButton(page, secondScrollerId);
        last = getLastButton(page, secondScrollerId);
        next = getNextButton(page, secondScrollerId);

        assertEquals("a", fastForward.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastfwd", fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("a", last.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-last", last.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("a", next.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-next", next.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        // check if left buttons is disabled
        HtmlElement fastRewind = getFastRewindButton(page, firstScrollerId);
        HtmlElement first = getFirstButton(page, firstScrollerId);
        HtmlElement previous = getPreviousButton(page, firstScrollerId);

        assertEquals("span", fastRewind.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastrwd rf-ds-dis", fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("span", first.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-first rf-ds-dis", first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("span", previous.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-prev rf-ds-dis", previous.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        fastRewind = getFastRewindButton(page, secondScrollerId);
        first = getFirstButton(page, secondScrollerId);
        next = getNextButton(page, secondScrollerId);

        assertEquals("span", fastRewind.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastrwd rf-ds-dis", fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("span", first.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-first rf-ds-dis", first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("span", previous.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-prev rf-ds-dis", previous.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
    }
View Full Code Here

        assertEquals("rf-ds-btn rf-ds-btn-prev rf-ds-dis", previous.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
    }

    private void checkLastPageButtons(HtmlPage page, String firstScrollerId, String secondScrollerId) throws Exception {
        // check if right buttons is disabled
        HtmlElement fastForward = getFastForwardButton(page, firstScrollerId);
        HtmlElement last = getLastButton(page, firstScrollerId);
        HtmlElement next = getNextButton(page, firstScrollerId);

        assertEquals("span", fastForward.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastfwd rf-ds-dis", fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("span", last.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-last rf-ds-dis", last.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("span", next.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-next rf-ds-dis", next.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        fastForward = getFastForwardButton(page, secondScrollerId);
        last = getFastForwardButton(page, secondScrollerId);
        next = getNextButton(page, secondScrollerId);

        assertEquals("span", fastForward.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastfwd rf-ds-dis", fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("span", last.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastfwd rf-ds-dis", last.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("span", next.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-next rf-ds-dis", next.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        // check if left buttons is enabled
        HtmlElement fastRewind = getFastRewindButton(page, firstScrollerId);
        HtmlElement first = getFirstButton(page, firstScrollerId);
        HtmlElement previous = getPreviousButton(page, firstScrollerId);

        assertEquals("a", fastRewind.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastrwd", fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("a", first.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-first", first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("a", previous.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-prev", previous.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        fastRewind = getFastRewindButton(page, secondScrollerId);
        first = getFirstButton(page, secondScrollerId);
        previous = getPreviousButton(page, secondScrollerId);

        assertEquals("a", fastRewind.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-fastrwd", fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("a", first.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-first", first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());

        assertEquals("a", previous.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-prev", previous.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
    }
View Full Code Here

        assertEquals("a", previous.getNodeName());
        assertEquals("rf-ds-btn rf-ds-btn-prev", previous.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
    }

    private String getCurrentPageContent(HtmlPage page, int i) throws Exception {
        HtmlElement content = page.getFirstByXPath("//*[@id = 'form:richTable:" + (--i) + ":pageContent']");
        DomNode text = content.getFirstChild();
        assertEquals(DomNode.TEXT_NODE, text.getNodeType());
        return text.getNodeValue();
    }
View Full Code Here

      // type it into this label
      assertTrue("Expected HtmlUnitElementImpl, but was " + element.getClass().getName(),
          element instanceof HtmlUnitElementImpl);

      // get the actual HtmlUnit element
      HtmlElement actual = ((HtmlUnitElementImpl) element).getHtmlElement();
      assertNotNull(actual);
     
      // type in the text
      actual.type(text);
     
      // wait until all background tasks (setTimeout, ...) are finished
      while (((HtmlUnitTestingEngineImpl) getTestingEngine()).getWebClient().waitForBackgroundJavaScript(500) != 0);
     
      // and return
View Full Code Here

      // type it into this label
      assertTrue("Expected HtmlUnitElementImpl, but was " + element.getClass().getName(),
          element instanceof HtmlUnitElementImpl);

      // get the actual HtmlUnit element
      HtmlElement actual = ((HtmlUnitElementImpl) element).getHtmlElement();
      assertNotNull(actual);
     
      // lose focus
      actual.blur();
     
      // and return
      return;
   
   
View Full Code Here

    Iterator<?> i = resultList.iterator();
    while( i.hasNext() )
    {
      try
      {
        HtmlElement htmlElement = ( HtmlElement )i.next();
        String path = htmlElement.getAttribute( "src" ).equals( "" ) ? htmlElement.getAttribute( "href" )
            : htmlElement.getAttribute( "src" );
        if( path == null || path.equals( "" ) )
          continue;
        URL url = htmlPage.getFullyQualifiedUrl( path );
        try
        {
View Full Code Here

    /**
     * <p>Test the "normal" flow of submitting a correctly entered form.</p>
     */
    public void testNormal() throws Exception {

        HtmlElement element = null;

        // setUp() should have put us on the page
        assertEquals("Exception Handling Test", title());

        // Submit the form
        HtmlSubmitInput submit = (HtmlSubmitInput) element("form:submit");
        submit(submit);

        // Validate that we have transferred to the exception handling page
        assertEquals("Exception Handling - Correct Result", title());

        // Validate the contents of selected fields
        element = element("form:status_code");
        assertNotNull(element);
        assertEquals("200", element.asText());
        element = element("form:exception_type");
        assertNotNull(element);
        assertEquals("org.apache.shale.view.ApplicationException", element.asText());

    }
View Full Code Here

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

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

        // setUp() should have put us on the page
        assertEquals("Exception Handling Test", title());
        form = (HtmlForm) element("form");
View Full Code Here

TOP

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

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.