Class TableElement
- All Implemented Interfaces:
CanCompareScreenshots,HasCallFunction,HasDriver,HasElementQuery,HasPropertySettersGetters,HasSearchContext,HasTestBenchCommandExecutor,org.openqa.selenium.SearchContext,org.openqa.selenium.TakesScreenshot,org.openqa.selenium.WebElement,org.openqa.selenium.WrapsElement
<table> element.- Since:
- 25.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns every row of this table, walking its sections in document order.Returns the<tbody>elements of this table, in document order.Returns the rows of this table's<tbody>elements, in document order.Returns this table's caption.getCell(int row, int column) Returns the cell at the given zero-based row and column of this table.getCellCovering(int row, int column) Returns the cell covering the given zero-based slot of this table as it appears on screen, resolvingcolspanandrowspan.intReturns how many columns wide this table is oncecolspanandrowspanare resolved, which is what the widest row occupies on screen rather than the largest number of cells any row writes.Returns the column groups of this table, in document order.getFoot()Returns this table's<tfoot>.Returns the rows of this table's<tfoot>.getHead()Returns this table's<thead>.Returns the rows of this table's<thead>.getRow(int index) Returns the row at the given zero-based position ingetAllRows(), so the index runs across the sections rather than within one.booleanReports whether this table has a<caption>, without failing if it does not.booleanhasFoot()Reports whether this table has a<tfoot>, without failing if it does not.booleanhasHead()Reports whether this table has a<thead>, without failing if it does not.Methods inherited from class com.vaadin.testbench.TestBenchElement
callFunction, clear, click, click, compareScreen, compareScreen, compareScreen, contextClick, dispatchEvent, dispatchEvent, doubleClick, equals, executeScript, findElement, findElements, focus, getAttribute, getCapabilities, getChildren, getClassNames, getCommandExecutor, getContext, getCssValue, getDomAttribute, getDomProperty, getDriver, getId, getLocation, getParent, getProperty, getPropertyBoolean, getPropertyDouble, getPropertyElement, getPropertyElements, getPropertyInteger, getPropertyString, getRect, getScreenshotAs, getShadowRoot, getSize, getTagName, getText, getWrappedElement, hasAttribute, hasClassName, hashCode, hover, init, init, isChrome, isDisplayed, isEnabled, isFirefox, isFocused, isReadOnly, isSelected, scroll, scrollIntoView, scrollIntoView, scrollLeft, sendKeys, setProperty, setProperty, setProperty, setProperty, submit, waitForVaadin, waitUntil, waitUntil, wrap, wrapElement, wrapElementsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.testbench.HasElementQuery
$, $Methods inherited from interface org.openqa.selenium.WebElement
getAccessibleName, getAriaRole
-
Constructor Details
-
TableElement
public TableElement()
-
-
Method Details
-
getAllRows
Returns every row of this table, walking its sections in document order. For a table rendered byTablethat is the<thead>rows, then the rows of each<tbody>, then the<tfoot>rows; on a page that writes the sections in some other order, the result follows the markup rather than that order.The name matches
Table.getAllRows(): this is the only row accessor here that spans every kind of section.getHeaderRows(),getBodyRows()andgetFooterRows()each stay within one kind ? though a table may have several<tbody>elements, sogetBodyRowsflattens those ? andTableSectionElement.getRows()returns the rows of a single element.- Returns:
- all the rows of this table.
-
getRow
Returns the row at the given zero-based position ingetAllRows(), so the index runs across the sections rather than within one.- Parameters:
index- the zero-based position of the row.- Returns:
- the row at that position.
-
getCell
Returns the cell at the given zero-based row and column of this table. Both indices are zero-based, as inGridElement.getCell. The row index runs across the sections, as ingetAllRows(); equivalent togetRow(row).getCells().get(column).The resemblance to
GridElement.getCellstops at the numbering, though. A grid is a strict rectangle whose column index picks a column rather than a position, so there every row has one cell per column and the two always agree. A table does not have to be rectangular.Both indices count elements as they are written, not grid positions. A cell carrying a
colspanorrowspanoccupies one position in the row it is written in and none at all in the rows or columns it reaches into, so on a table with spans these indices drift away from what is on screen. Given:<tr><th rowspan="2">Helsinki</th><td>Travel</td></tr> <tr><td>Design</td></tr>getCell(0, 0)is the<th>andgetCell(0, 1)is "Travel", whilegetCell(1, 0)is "Design" ? not the<th>that visually covers that position, and there is no index at which the second row yields it. To assert on a spanned cell, reach it through the row that writes it and check itsrowspanorcolspanattribute.- Parameters:
row- the zero-based position of the row ingetAllRows().column- the zero-based position of the cell within that row, counting only the cells that row writes.- Returns:
- the cell at that position.
-
getHeaderRows
Returns the rows of this table's<thead>.- Returns:
- the header rows, or an empty list if the table has no
<thead>.
-
getBodyRows
Returns the rows of this table's<tbody>elements, in document order. UsegetBodies()to keep them grouped by body.- Returns:
- the body rows, or an empty list if the table has no
<tbody>.
-
getBodies
Returns the<tbody>elements of this table, in document order. A table may have several, each holding its own rows.- Returns:
- the table bodies.
-
getHead
Returns this table's<thead>.- Returns:
- the header section.
- Throws:
org.openqa.selenium.NoSuchElementException- if the table has none. AskhasHead()first to check without failing;getHeaderRows()is not the same question, since an empty<thead>has no rows.
-
hasHead
public boolean hasHead()Reports whether this table has a<thead>, without failing if it does not.- Returns:
trueif the section is present.
-
getFoot
Returns this table's<tfoot>.- Returns:
- the footer section.
- Throws:
org.openqa.selenium.NoSuchElementException- if the table has none. AskhasFoot()first to check without failing;getFooterRows()is not the same question, since an empty<tfoot>has no rows.
-
hasFoot
public boolean hasFoot()Reports whether this table has a<tfoot>, without failing if it does not.- Returns:
trueif the section is present.
-
getCaption
Returns this table's caption.- Returns:
- the
<caption>. - Throws:
org.openqa.selenium.NoSuchElementException- if the table has none. AskhasCaption()first to check without failing.
-
hasCaption
public boolean hasCaption()Reports whether this table has a<caption>, without failing if it does not.- Returns:
trueif the caption is present.
-
getColumnGroups
Returns the column groups of this table, in document order.- Returns:
- the table's
<colgroup>elements.
-
getColumnCount
public int getColumnCount()Returns how many columns wide this table is oncecolspanandrowspanare resolved, which is what the widest row occupies on screen rather than the largest number of cells any row writes.The layout is computed in the browser, and only the count comes back, so this is one round trip whatever the size of the table.
- Returns:
- the number of columns, or 0 for a table with no cells.
-
getCellCovering
Returns the cell covering the given zero-based slot of this table as it appears on screen, resolvingcolspanandrowspan. WheregetCell(int, int)counts the cells a row writes, this counts the positions a reader sees, so a cell spanning two rows is returned for both of them.The layout is computed in the browser, so this is a single round trip rather than one per cell; the whole grid comes back with it, though, and nothing is cached, since the page is free to change between calls. Reach for the slots an assertion is about rather than walking every slot of a large table.
- Parameters:
row- the zero-based row of the slot.column- the zero-based column of the slot.- Returns:
- the cell covering that slot.
- Throws:
org.openqa.selenium.NoSuchElementException- if the table has no such slot, or no cell reaches it.- See Also:
-