Package com.gargoylesoftware.htmlunit.html

Examples of com.gargoylesoftware.htmlunit.html.HtmlElement


    *                            specified component is not an HtmlElement.
    * @throws IOExceptioin if typing causes a failed request to the server.
    */
   public void type(String componentID, char c) throws IOException
   {
      HtmlElement element = (HtmlElement)getElement(componentID);
      if (element == null) throw new ComponentIDNotFoundException(componentID);
      element.type(c);
   }
View Full Code Here


      String clientID = jsfServerSession.getClientIDs().findClientID(componentID);
      HtmlPage htmlPage = (HtmlPage)getContentPage();
      List<HtmlElement> elements = htmlPage.getHtmlElementsByName(clientID);
      for (Iterator<HtmlElement> i = elements.iterator(); i.hasNext();)
      {
         HtmlElement htmlElement = i.next();
         if ((htmlElement instanceof HtmlRadioButtonInput) &&
             (htmlElement.getAttribute("value").equals(optionToSelect)))
         {
            return (HtmlRadioButtonInput)htmlElement;
         }
      }
     
View Full Code Here

    /**
     * Top page should only have one item in the breadcrumb.
     */
    public void testBreadcrumb() throws Exception {
        HtmlPage root = new WebClient().goTo("");
        HtmlElement navbar = root.getElementById("breadcrumbs");
        assertEquals(1,navbar.selectNodes("LI/A").size());
    }
View Full Code Here

  String testUrl = cr.getRelativePathFrom(tr);
 
  HtmlPage page = new WebClient().goTo("job/render-test/1/testReport/" + testUrl);

  HtmlElement errorMsg = (HtmlElement) page.getByXPath("//h3[text()='Error Message']/following-sibling::*").get(0);

  assertEquals(cr.annotate(cr.getErrorDetails()).replaceAll("&lt;", "<"), errorMsg.getTextContent());
  HtmlElement errorStackTrace = (HtmlElement) page.getByXPath("//h3[text()='Stacktrace']/following-sibling::*").get(0);
  // Have to do some annoying replacing here to get the same text Jelly produces in the end.
  assertEquals(cr.annotate(cr.getErrorStackTrace()).replaceAll("&lt;", "<").replace("\r\n", "\n"),
         errorStackTrace.getTextContent());
    }
View Full Code Here

    }

    @Test
    public void testExistenceCalendarPopup() throws Exception {
        HtmlPage page = environment.getPage("/calendarTest.jsf");
        HtmlElement calendarPopupElement = (HtmlElement) page.getElementById("form:calendarPopup");
        Assert.assertNotNull("form:calendarPopup element missed.", calendarPopupElement);
    }
View Full Code Here

    }

    @Test
    public void testExistenceCalendarContent() throws Exception {
        HtmlPage page = environment.getPage("/calendarTest.jsf");
        HtmlElement calendarContentElement = (HtmlElement) page.getElementById("form:calendarContent");
        Assert.assertNotNull("form:calendarContent element missed.", calendarContentElement);
    }
View Full Code Here

        HtmlPage page = environment.getPage("/calendarTest.jsf");

        HtmlImage calendarPopupButton = (HtmlImage) page.getElementById("form:calendarPopupButton");
        assertNotNull(calendarPopupButton);
        page = (HtmlPage) calendarPopupButton.click();
        HtmlElement calendarHeaderElement = page.getHtmlElementById("form:calendarHeader");
        assertNotNull("form:calendarHeader element missed.", calendarHeaderElement);

        HtmlTableDataCell nextTD = null;
        List<?> tds = calendarHeaderElement.getByXPath("table/tbody/tr/td");
        for (Object td : tds) {
            HtmlTableDataCell htdc = (HtmlTableDataCell) td;
            if (">".equals(htdc.asText())) {
                nextTD = htdc;
            }
        }
        assertNotNull(nextTD);
        HtmlElement div = (HtmlElement) nextTD.getChildElements().iterator().next();

        // Before click
        Calendar calendar = Calendar.getInstance();
        calendar.set(CalendarBean.CURRENT_YEAR, CalendarBean.CURRENT_MONTH, CalendarBean.CURRENT_DAY);
        String month = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.US);
        assertTrue(calendarHeaderElement.asText().indexOf(month) > -1);

        page = div.click();

        // After click
        calendar.add(Calendar.MONTH, 1);
        month = calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.US);
        assertTrue(calendarHeaderElement.asText().indexOf(month) > -1);
View Full Code Here

    @Test
    public void testSetValueListLayout() throws Exception {
        environment.getWebClient().getOptions().setJavaScriptEnabled(true);
        HtmlPage page = environment.getPage("/autocompleteListLayoutTest.jsf");
        HtmlElement autocompleteList = (HtmlElement) page.getElementById("form:myAutocompleteList");
        Assert.assertNotNull(autocompleteList);

        List<?> countryList = autocompleteList.getByXPath("div/div/div/ul/li");
        Assert.assertEquals(30, countryList.size());

        HtmlInput input = (HtmlInput) page.getElementById("form:myAutocompleteInput");
        Assert.assertNotNull(input);
        input.type("be");

        for (int i = 0; i < 20; i++) {
            synchronized (page) {
                autocompleteList = (HtmlElement) page.getElementById("form:myAutocompleteList");
                Assert.assertNotNull(autocompleteList);

                countryList = autocompleteList.getByXPath("div/div/div/ul/li");

                if (countryList.size() == 5) {
                    break;
                } else {
                    page.wait(500);
View Full Code Here

    }

    @Test
    public final void testDoEncodeChildren() throws IOException {
        HtmlPage page = environment.getPage("/dataGridTest.jsf");
        HtmlElement dataGrid = (HtmlElement) page.getElementById("dataGrid2");
        assertEquals("rf-dg", dataGrid.getAttribute("class"));
        assertEquals("noDataFacet",
            ((HtmlElement) dataGrid
                .getFirstByXPath("tbody/tr[@class='rf-dg-nd']/td[@class='rf-dg-nd-c']/*[@id='dataGrid2:noDataFacet']"))
                .getTextContent());
    }
View Full Code Here

    }

    @Test
    public final void testEncodeRow() throws IOException {
        HtmlPage page = environment.getPage("/dataGridTest.jsf");
        HtmlElement dataGrid = (HtmlElement) page.getElementById("dataGrid");
        assertEquals("value",
            ((HtmlElement) dataGrid
                .getFirstByXPath("tbody/tr[@class='rf-dg-r']/td[@class='rf-dg-c']/*[@id='dataGrid:0:outputText']"))
                .getTextContent());
    }
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.