Directory

← Back

HTML Table Testbench elements

HTML Table Testbench Elements

Author

Rating

Popularity

<100

A set of Testbench Elements for the HTML Table addon for custom Vaadin Testbench UI tests.

@see https://vaadin.com/directory/component/html-table.

Sample code

// SimpleTestView.java
@Route("simple")
public class SimpleTableView extends Div {

    public SimpleTableView() {
        Table table = new Table();
        table.setWidth("500px");

        TableRow headerRow = table.addRow();
        headerRow.addHeaderCell().setText("Hello");
        headerRow.addHeaderCell().setText("World");

        TableRow detailsRow = table.addRow();
        detailsRow.addDataCell().setText("Hello");
        detailsRow.addDataCell().setText("World");

        add(table);
    }
}

// SimpleTestViewIT.java
public class SimpleTableViewIT extends TestBenchTestCase {

    // ... test setup and init

    @Test
    public void componentWorks() {
        TableElement table = getTable();

        Assert.assertFalse("caption" + " must not be present", table.getOptionalCaption().isPresent());
        Assert.assertFalse("colgroup" + " must not be present", table.getOptionalColumn().isPresent());
        Assert.assertFalse("thead" + " must not be present", table.getOptionalHead().isPresent());
        Assert.assertFalse("tbody" + " must not be present", table.getOptionalBody().isPresent());
        Assert.assertFalse("tfoot" + " must not be present", table.getOptionalFoot().isPresent());

        List<TableRowElement> rows = table.getRows();
        Assert.assertEquals(2, rows.size());

        TableRowElement row = rows.get(0);
        List<TableHeaderCellElement> headerCells = row.getHeaderCells();
        List<TableDataCellElement> dataCells = row.getDataCells();
        Assert.assertEquals(2, headerCells.size());
        Assert.assertEquals(0, dataCells.size());

        Assert.assertEquals("Hello", headerCells.get(0).getText());
        Assert.assertEquals("World", headerCells.get(1).getText());

        row = rows.get(1);
        headerCells = row.getHeaderCells();
        dataCells = row.getDataCells();
        Assert.assertEquals(0, headerCells.size());
        Assert.assertEquals(2, dataCells.size());

        Assert.assertEquals("Hello", dataCells.get(0).getText());
        Assert.assertEquals("World", dataCells.get(1).getText());
    }
    
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Integrated support for multiple tbody elements.

Released
2022-07-07
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 14+
Browser
N/A

HTML Table Testbench elements - Vaadin Add-on Directory

HTML Table Testbench Elements HTML Table Testbench elements - Vaadin Add-on Directory
A set of Testbench Elements for the **HTML Table** addon for custom Vaadin Testbench UI tests. @see https://vaadin.com/directory/component/html-table.
View on GitHub
Issue tracker

HTML Table Testbench elements version 1.0.0

HTML Table Testbench elements version 1.1.0
- aligned versions with the main addon - updated to the latest Vaadin 14

HTML Table Testbench elements version 1.1.1
- aligned versions with the main addon - updated to the latest Vaadin 14

HTML Table Testbench elements version 1.2.0
Integrated support for multiple tbody elements.

Online