Search in sources :

Example 1 with HtmlTableDataCell

use of com.gargoylesoftware.htmlunit.html.HtmlTableDataCell in project htmlunit by HtmlUnit.

the class HTMLElement method getOffsetParentInternal.

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;
}
Also used : DomNode(com.gargoylesoftware.htmlunit.html.DomNode) HtmlBody(com.gargoylesoftware.htmlunit.html.HtmlBody) HtmlTable(com.gargoylesoftware.htmlunit.html.HtmlTable) HtmlTableDataCell(com.gargoylesoftware.htmlunit.html.HtmlTableDataCell) ComputedCSSStyleDeclaration(com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration)

Example 2 with HtmlTableDataCell

use of com.gargoylesoftware.htmlunit.html.HtmlTableDataCell in project htmlunit by HtmlUnit.

the class GWT250Test method mail.

/**
 * @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, foo@example.com");
    final String[] selectedRow = { "markboland05", "mark@example.com", "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");
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlElement(com.gargoylesoftware.htmlunit.html.HtmlElement) HtmlTableDataCell(com.gargoylesoftware.htmlunit.html.HtmlTableDataCell) HtmlDivision(com.gargoylesoftware.htmlunit.html.HtmlDivision) Test(org.junit.Test)

Example 3 with HtmlTableDataCell

use of com.gargoylesoftware.htmlunit.html.HtmlTableDataCell in project htmlunit by HtmlUnit.

the class GWT250Test method dynaTable.

/**
 * @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]);
    }
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlTableDataCell(com.gargoylesoftware.htmlunit.html.HtmlTableDataCell) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Aggregations

HtmlTableDataCell (com.gargoylesoftware.htmlunit.html.HtmlTableDataCell)3 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2 Test (org.junit.Test)2 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 DomNode (com.gargoylesoftware.htmlunit.html.DomNode)1 HtmlBody (com.gargoylesoftware.htmlunit.html.HtmlBody)1 HtmlDivision (com.gargoylesoftware.htmlunit.html.HtmlDivision)1 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)1 HtmlTable (com.gargoylesoftware.htmlunit.html.HtmlTable)1 ComputedCSSStyleDeclaration (com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration)1