From 4454e6bdc13dec8198c9e5e95557fcf59f9f97e4 Mon Sep 17 00:00:00 2001 From: Artur Date: Thu, 13 Apr 2017 10:25:20 +0300 Subject: Provide GridLayout size and cell elements to JS and TB (#9019) --- .../testbench/elements/GridLayoutElement.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'testbench-api/src/main') 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; + } } -- cgit v1.2.3