aboutsummaryrefslogtreecommitdiffstats
path: root/uitest-common
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2016-09-13 12:31:08 +0300
committerVaadin Code Review <review@vaadin.com>2016-09-14 07:55:54 +0000
commit13e3d235e5ce62ad03a2da0046162e10bd5bd94c (patch)
treeab0d95605fa1ff865e015c3294054f73d49816e3 /uitest-common
parent7c2c1e614a1de491473877aba06cd6d81b7b2530 (diff)
downloadvaadin-framework-13e3d235e5ce62ad03a2da0046162e10bd5bd94c.tar.gz
vaadin-framework-13e3d235e5ce62ad03a2da0046162e10bd5bd94c.zip
Add multi selection support to CheckBoxGroup
This patch adds multi selection support only for CheckBoxGroup without even trying to generalize anything. Adopting the concepts to work with other components will be done separately. Change-Id: Id4ccd2c743b74cb022dc9dfd8cd8dae3bf8f0c54
Diffstat (limited to 'uitest-common')
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java34
1 files changed, 21 insertions, 13 deletions
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java
index b070ece852..b2dd93a7b0 100644
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java
+++ b/uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -32,13 +32,13 @@ import com.vaadin.testbench.elementsbase.ServerClass;
@ServerClass("com.vaadin.ui.CheckBoxGroup")
public class CheckBoxGroupElement extends AbstractSelectElement {
- private static org.openqa.selenium.By byButtonSpan =
- By.className("v-select-option");
+ private static org.openqa.selenium.By byButtonSpan = By
+ .className("v-select-option");
private static org.openqa.selenium.By byLabel = By.tagName("label");
private static org.openqa.selenium.By byInput = By.tagName("input");
public List<String> getOptions() {
- List<String> optionTexts = new ArrayList<String>();
+ List<String> optionTexts = new ArrayList<>();
List<WebElement> options = findElements(byButtonSpan);
for (WebElement option : options) {
optionTexts.add(option.findElement(byLabel).getText());
@@ -51,9 +51,17 @@ public class CheckBoxGroupElement extends AbstractSelectElement {
throw new ReadOnlyException();
}
List<WebElement> options = findElements(byButtonSpan);
- for (WebElement option : options) {
+ for (int i = 0; i < options.size(); i++) {
+ WebElement option = options.get(i);
if (text.equals(option.findElement(byLabel).getText())) {
option.findElement(byInput).click();
+
+ // Seems like this is needed because of #19753
+ waitForVaadin();
+
+ // Toggling selection causes the DOM to be rebuilt, so fetch new
+ // items and continue iterating from the same index
+ options = findElements(byButtonSpan);
}
}
}
@@ -70,8 +78,8 @@ public class CheckBoxGroupElement extends AbstractSelectElement {
WebElement checkedItem;
checkedItem = option.findElement(By.tagName("input"));
String checked = checkedItem.getAttribute("checked");
- if (checked != null &&
- checkedItem.getAttribute("checked").equals("true")) {
+ if (checked != null
+ && checkedItem.getAttribute("checked").equals("true")) {
values.add(option.findElement(By.tagName("label")).getText());
}
}
@@ -82,7 +90,8 @@ public class CheckBoxGroupElement extends AbstractSelectElement {
* Select option in the checkbox group with the specified value
*
* @param chars
- * value of the option in the checkbox group which will be selected
+ * value of the option in the checkbox group which will be
+ * selected
*/
public void selectOption(CharSequence chars) throws ReadOnlyException {
selectByText((String) chars);
@@ -91,8 +100,7 @@ public class CheckBoxGroupElement extends AbstractSelectElement {
@Override
public void clear() {
throw new UnsupportedOperationException(
- "Clear operation is not supported for CheckBoxGroup." +
- " This operation has no effect on the element.");
+ "Clear operation is not supported for CheckBoxGroup."
+ + " This operation has no effect on the element.");
}
}
-