aboutsummaryrefslogtreecommitdiffstats
path: root/testbench-api
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-05-03 13:37:56 +0300
committerHenri Sara <henri.sara@gmail.com>2017-05-03 13:37:56 +0300
commit3a7e95b98af0e9ad8f1d0160f6a1adcaa6cd8c58 (patch)
tree2345a81dea9a65f7fab763e3ba197ac82c04e51e /testbench-api
parent8a77872050b8b51013261458d2c766dc93ff6c11 (diff)
downloadvaadin-framework-3a7e95b98af0e9ad8f1d0160f6a1adcaa6cd8c58.tar.gz
vaadin-framework-3a7e95b98af0e9ad8f1d0160f6a1adcaa6cd8c58.zip
Fix minor issues with Tree theme and TB API (#9226)
Removes background color from Tree, adds release notes mention, JavaDoc updates.
Diffstat (limited to 'testbench-api')
-rw-r--r--testbench-api/src/main/java/com/vaadin/testbench/elements/TreeElement.java32
1 files changed, 24 insertions, 8 deletions
diff --git a/testbench-api/src/main/java/com/vaadin/testbench/elements/TreeElement.java b/testbench-api/src/main/java/com/vaadin/testbench/elements/TreeElement.java
index 80f90fd349..371cc8b31f 100644
--- a/testbench-api/src/main/java/com/vaadin/testbench/elements/TreeElement.java
+++ b/testbench-api/src/main/java/com/vaadin/testbench/elements/TreeElement.java
@@ -17,6 +17,7 @@ package com.vaadin.testbench.elements;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
@@ -109,25 +110,40 @@ public class TreeElement extends AbstractComponentElement {
}
/**
- * Gets all items currently shown in this tree.
+ * Gets all items currently shown in this tree. The returned element objects
+ * are the rendered contents for each item.
*
- * @return list of all items
+ * @return list of content elements for all items
*/
public List<TestBenchElement> getAllItems() {
- return TestBenchElement.wrapElements(
- asTreeGrid().getBody().findElements(By.tagName("tr")),
- getCommandExecutor());
+ return asTreeGrid().getBody().findElements(By.tagName("tr")).stream()
+ .map(this::findCellContentFromRow).collect(Collectors.toList());
}
/**
- * Gets an item at given index.
+ * Gets an item at given index. The returned element object is the rendered
+ * content in the given index.
*
* @param index
* 0-based row index
- * @return item at given index
+ * @return content element for item at given index
*/
public TestBenchElement getItem(int index) {
- return asTreeGrid().getCell(index, 0);
+ return findCellContentFromRow(asTreeGrid().getRow(index));
+ }
+
+ /**
+ * Finds the rendered cell content from given row element. This expects the
+ * row to contain only a single column rendered with TreeRenderer.
+ *
+ * @param rowElement
+ * the row element
+ * @return cell content element
+ */
+ protected TestBenchElement findCellContentFromRow(WebElement rowElement) {
+ return TestBenchElement.wrapElement(
+ rowElement.findElement(By.className("gwt-HTML")),
+ getCommandExecutor());
}
/**