diff options
Diffstat (limited to 'testbench-api/src')
-rw-r--r-- | testbench-api/src/main/java/com/vaadin/testbench/elements/GridLayoutElement.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/GridLayoutElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/GridLayoutElement.java index 31ebca721d..4f3106356a 100644 --- a/testbench-api/src/main/java/com/vaadin/testbench/elements/GridLayoutElement.java +++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/GridLayoutElement.java @@ -15,9 +15,64 @@ */ package com.vaadin.testbench.elements; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; + import com.vaadin.testbench.elementsbase.ServerClass; @ServerClass("com.vaadin.ui.GridLayout") public class GridLayoutElement extends AbstractLayoutElement { + /** + * Gets the total number of rows in the layout. + * + * @return the number of rows in the layout, + */ + public long getRowCount() { + Long res = (Long) getCommandExecutor() + .executeScript("return arguments[0].getRowCount()", this); + if (res == null) { + throw new IllegalStateException("getRowCount returned null"); + } + + return res.longValue(); + } + + /** + * Gets the total number of columns in the layout. + * + * @return the number of columns in the layout, + */ + public long getColumnCount() { + Long res = (Long) getCommandExecutor() + .executeScript("return arguments[0].getColumnCount()", this); + if (res == null) { + throw new IllegalStateException("getColumnCount returned null"); + } + + return res.longValue(); + } + + /** + * Gets the cell element at the given position. + * + * @param row + * the row coordinate + * @param column + * the column coordinate + * @return the cell element at the given position + * @throws NoSuchElementException + * if no cell was found at the given position + */ + public WebElement getCell(int row, int column) { + WebElement res = (WebElement) getCommandExecutor().executeScript( + "return arguments[0].getCell(" + row + "," + column + ")", + this); + if (res == null) { + throw new NoSuchElementException( + "No cell found at " + row + "," + column); + } + + return res; + } } |