aboutsummaryrefslogtreecommitdiffstats
path: root/testbench-api/src/main
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-04-13 10:25:20 +0300
committerAleksi Hietanen <aleksi@vaadin.com>2017-04-13 10:25:20 +0300
commit4454e6bdc13dec8198c9e5e95557fcf59f9f97e4 (patch)
treee9a37b2b92e709e7f4404ab3eb65d4974e9481df /testbench-api/src/main
parent60a6e0282e8e013acb56821f30573c65f1a6c36d (diff)
downloadvaadin-framework-4454e6bdc13dec8198c9e5e95557fcf59f9f97e4.tar.gz
vaadin-framework-4454e6bdc13dec8198c9e5e95557fcf59f9f97e4.zip
Provide GridLayout size and cell elements to JS and TB (#9019)
Diffstat (limited to 'testbench-api/src/main')
-rw-r--r--testbench-api/src/main/java/com/vaadin/testbench/elements/GridLayoutElement.java55
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;
+ }
}