com.gargoylesoftware.htmlunit.html.HtmlTableDataCell Java Examples

The following examples show how to use com.gargoylesoftware.htmlunit.html.HtmlTableDataCell. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GWT250Test.java    From htmlunit with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception if an error occurs
 */
@Test
public void dynaTable() throws Exception {
    startWebServer("src/test/resources/libraries/GWT/" + getDirectory() + "/DynaTable",
            new String[] {"src/test/resources/libraries/GWT/" + getDirectory() + "/gwt-servlet.jar"});

    final WebClient client = getWebClient();

    final String url = URL_FIRST + "DynaTable.html";
    final HtmlPage page = client.getPage(url);
    client.waitForBackgroundJavaScriptStartingBefore(2000);

    final String[] firstRow = {"Inman Mendez",
        "Majoring in Phrenology", "Mon 9:45-10:35, Tues 2:15-3:05, Fri 8:45-9:35, Fri 9:45-10:35"};

    final List<?> detailsCells = page.getByXPath("//table[@class='table']//tr[2]/td");
    assertEquals(firstRow.length, detailsCells.size());
    for (int i = 0; i < firstRow.length; i++) {
        final HtmlTableDataCell cell = (HtmlTableDataCell) detailsCells.get(i);
        assertElementValue(cell, firstRow[i]);
    }
}
 
Example #2
Source File: GWT250Test.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if an error occurs
 */
@Test
public void mail() throws Exception {
    final HtmlPage page = loadGWTPage("Mail", null, "//div[@class='MGJ']");
    assertSame(page.getEnclosingWindow(), page.getWebClient().getCurrentWindow());
    final HtmlDivision cell = page.getFirstByXPath("//div[@class='MGJ']");
    assertElementValue(cell, "Welcome back, [email protected]");

    final String[] selectedRow = {"markboland05", "[email protected]", "URGENT -[Mon, 24 Apr 2006 02:17:27 +0000]"};

    final List<?> selectedRowCells = page.getByXPath("//tr[@class='MKI']/td");
    assertEquals(selectedRow.length, selectedRowCells.size());
    for (int i = 0; i < selectedRow.length; i++) {
        final HtmlTableDataCell selectedRowCell = (HtmlTableDataCell) selectedRowCells.get(i);
        assertElementValue(selectedRowCell, selectedRow[i]);
    }

    verifyStartMailBody(page, "Dear Friend,",
            "I am Mr. Mark Boland the Bank Manager of ABN AMRO BANK 101 Moorgate, London, EC2M 6SB.");

    // click on email from Hollie Voss
    final HtmlElement elt = page.getFirstByXPath("//td[text() = 'Hollie Voss']");
    final HtmlPage page2 = elt.click();
    assertSame(page, page2);
    verifyStartMailBody(page, ">> Componentes e decodificadores; confira aqui;",
            "http://br.geocities.com/listajohn/index.htm",
            "THE GOVERNING AWARD");
}
 
Example #3
Source File: UIServletTest.java    From celos with Apache License 2.0 5 votes vote down vote up
@Test
public void testRender() throws Exception {
    ScheduledTime end = new ScheduledTime("2015-09-03T13:17Z");
    ScheduledTime start = new ScheduledTime("2015-09-03T13:11Z");
    NavigableSet<ScheduledTime> tileTimes = new TreeSet<>(ImmutableSet.of(new ScheduledTime("2015-09-03T13:10Z"), new ScheduledTime("2015-09-03T13:15Z")));
    WorkflowID id = new WorkflowID("foo");
    List<WorkflowGroup> groups = ImmutableList.of(new WorkflowGroup("All workflows", ImmutableList.of(id)));
    WorkflowInfo workflowInfo = new WorkflowInfo(new URL("http://example.com"), ImmutableList.of());
    SlotState state1 = new SlotState(new SlotID(id, new ScheduledTime("2015-09-03T13:16Z")), SlotState.Status.FAILURE);
    SlotState state2 = new SlotState(new SlotID(id, new ScheduledTime("2015-09-03T13:12Z")), SlotState.Status.WAITING);
    List<SlotState> slotStates = ImmutableList.of(state1, state2);
    Map<WorkflowID, WorkflowStatus> statuses = ImmutableMap.of(id, new WorkflowStatus(workflowInfo, slotStates, false));
    UIConfiguration conf = new UIConfiguration(start, end, tileTimes, groups, statuses, new URL("http://example.com"));
    
    StringWebResponse response = new StringWebResponse(UIServlet.render(conf), new URL("http://example.com"));
    WebClient webClient = new WebClient();
    webClient.setThrowExceptionOnFailingStatusCode(false);
    HtmlPage page = HTMLParser.parse(response, new TopLevelWindow("top", webClient));
    
    // Some basic sanity checking
    
    List<HtmlTableDataCell> slotCells = (List<HtmlTableDataCell>) page.getByXPath("//td[contains(@class, 'slot')]");
    Assert.assertEquals("fail", slotCells.get(0).getTextContent());
    Assert.assertEquals("wait", slotCells.get(1).getTextContent());
    
    List<HtmlTableDataCell> hourCells = (List<HtmlTableDataCell>) page.getByXPath("//td[contains(@class, 'hour')]");
    Assert.assertEquals("1315", hourCells.get(0).getTextContent());
    Assert.assertEquals("1310", hourCells.get(1).getTextContent());
    
    List<HtmlTableDataCell> workflowCells = (List<HtmlTableDataCell>) page.getByXPath("//td[@class='workflow']");
    Assert.assertEquals("foo", workflowCells.get(0).getTextContent());
    
    System.out.println(response.getContentAsString());
}
 
Example #4
Source File: HTMLElement.java    From htmlunit with Apache License 2.0 4 votes vote down vote up
private Object getOffsetParentInternal(final boolean returnNullIfFixed) {
    DomNode currentElement = getDomNodeOrDie();

    if (currentElement.getParentNode() == null) {
        return null;
    }

    final HTMLElement htmlElement = currentElement.getScriptableObject();
    if (returnNullIfFixed && "fixed".equals(htmlElement.getStyle().getStyleAttribute(
            StyleAttributes.Definition.POSITION, true))) {
        return null;
    }

    final ComputedCSSStyleDeclaration style = htmlElement.getWindow().getComputedStyle(htmlElement, null);
    final String position = style.getPositionWithInheritance();
    final boolean staticPos = "static".equals(position);

    while (currentElement != null) {

        final DomNode parentNode = currentElement.getParentNode();
        if (parentNode instanceof HtmlBody
            || (staticPos && parentNode instanceof HtmlTableDataCell)
            || (staticPos && parentNode instanceof HtmlTable)) {
            return parentNode.getScriptableObject();
        }

        if (parentNode != null && parentNode.getScriptableObject() instanceof HTMLElement) {
            final HTMLElement parentElement = parentNode.getScriptableObject();
            final ComputedCSSStyleDeclaration parentStyle =
                        parentElement.getWindow().getComputedStyle(parentElement, null);
            final String parentPosition = parentStyle.getPositionWithInheritance();
            if (!"static".equals(parentPosition)) {
                return parentNode.getScriptableObject();
            }
        }

        currentElement = currentElement.getParentNode();
    }

    return null;
}
 
Example #5
Source File: HTMLElement.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
private Object getOffsetParentInternal(final boolean returnNullIfFixed) {
    DomNode currentElement = getDomNodeOrDie();

    if (currentElement.getParentNode() == null) {
        return null;
    }

    Object offsetParent = null;
    final HTMLElement htmlElement = (HTMLElement) currentElement.getScriptableObject();
    if (returnNullIfFixed && "fixed".equals(htmlElement.getStyle().getStyleAttribute(
            StyleAttributes.Definition.POSITION, true))) {
        return null;
    }

    final ComputedCSSStyleDeclaration style = htmlElement.getWindow().getComputedStyle(htmlElement, null);
    final String position = style.getPositionWithInheritance();
    final boolean staticPos = "static".equals(position);

    final boolean useTables = staticPos;

    while (currentElement != null) {

        final DomNode parentNode = currentElement.getParentNode();
        if (parentNode instanceof HtmlBody
            || (useTables && parentNode instanceof HtmlTableDataCell)
            || (useTables && parentNode instanceof HtmlTable)) {
            offsetParent = parentNode.getScriptableObject();
            break;
        }

        if (parentNode != null && parentNode.getScriptableObject() instanceof HTMLElement) {
            final HTMLElement parentElement = (HTMLElement) parentNode.getScriptableObject();
            final ComputedCSSStyleDeclaration parentStyle =
                        parentElement.getWindow().getComputedStyle(parentElement, null);
            final String parentPosition = parentStyle.getPositionWithInheritance();
            final boolean parentIsStatic = "static".equals(parentPosition);
            if (!parentIsStatic) {
                offsetParent = parentNode.getScriptableObject();
                break;
            }
        }

        currentElement = currentElement.getParentNode();
    }

    return offsetParent;
}