com.gargoylesoftware.htmlunit.html.HtmlTableBody Java Examples

The following examples show how to use com.gargoylesoftware.htmlunit.html.HtmlTableBody. 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: PropertyTable.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Creates a new instance of {@link PropertyTable}.
 *
 * @param page
 *         the whole details HTML page
 * @param property
 *         the property tab to extract
 */
@SuppressFBWarnings("BC")
public PropertyTable(final HtmlPage page, final String property) {
    super(page);

    title = getTitleOfTable(page, property);

    DomElement propertyElement = page.getElementById(property);
    assertThat(propertyElement).isInstanceOf(HtmlTable.class);

    HtmlTable table = (HtmlTable) propertyElement;
    List<HtmlTableRow> tableHeaderRows = table.getHeader().getRows();
    assertThat(tableHeaderRows).hasSize(1);

    HtmlTableRow header = tableHeaderRows.get(0);
    List<HtmlTableCell> cells = header.getCells();
    assertThat(cells).hasSize(3);

    propertyName = cells.get(0).getTextContent();
    assertThat(cells.get(1).getTextContent()).isEqualTo("Total");
    assertThat(cells.get(2).getTextContent()).isEqualTo("Distribution");

    List<HtmlTableBody> bodies = table.getBodies();
    assertThat(bodies).hasSize(1);
    List<HtmlTableRow> contentRows = bodies.get(0).getRows();

    for (HtmlTableRow row : contentRows) {
        List<HtmlTableCell> rowCells = row.getCells();
        rows.add(new PropertyRow(rowCells));
    }
}