summaryrefslogtreecommitdiffstats
path: root/uitest-common
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2016-12-13 16:13:05 +0200
committerGitHub <noreply@github.com>2016-12-13 16:13:05 +0200
commit12793c9667cb2708ddfbcfe0d94364dd0dc607e3 (patch)
tree4edaedc078689ff26a91bab3357efe625047ffcd /uitest-common
parenta43fd9003a77f253a78b807d4ecadcd828b936a4 (diff)
downloadvaadin-framework-12793c9667cb2708ddfbcfe0d94364dd0dc607e3.tar.gz
vaadin-framework-12793c9667cb2708ddfbcfe0d94364dd0dc607e3.zip
Fix broken test for RadioButtonGroup and CheckBoxGroup (#7970)
Selection by clicking options was broken on Chrome 40 on Windows. Switched the custom element to extend corresponding elements from TestBench API.
Diffstat (limited to 'uitest-common')
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/CheckBoxGroupElement.java36
-rw-r--r--uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java44
2 files changed, 8 insertions, 72 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 9b234fa1cd..e8a05cb194 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
@@ -21,31 +21,19 @@ import java.util.List;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.By;
-import com.vaadin.testbench.elements.AbstractSelectElement;
-import com.vaadin.testbench.elementsbase.ServerClass;
/**
* TestBench element supporting CheckBoxGroup
*
* @author Vaadin Ltd
*/
-
-@ServerClass("com.vaadin.ui.CheckBoxGroup")
-public class CheckBoxGroupElement extends AbstractSelectElement {
+public class CheckBoxGroupElement
+ extends com.vaadin.testbench.elements.CheckBoxGroupElement {
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<>();
- List<WebElement> options = findElements(byButtonSpan);
- for (WebElement option : options) {
- optionTexts.add(option.findElement(byLabel).getText());
- }
- return optionTexts;
- }
-
public List<String> getOptionsCssClasses() {
List<String> optionTexts = new ArrayList<>();
List<WebElement> options = findElements(byButtonSpan);
@@ -70,26 +58,6 @@ public class CheckBoxGroupElement extends AbstractSelectElement {
return icons;
}
- public void selectByText(String text) throws ReadOnlyException {
- if (isReadOnly()) {
- throw new ReadOnlyException();
- }
- List<WebElement> options = findElements(byButtonSpan);
- 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);
- }
- }
- }
-
/**
* Return list of the selected options in the checkbox group
*
diff --git a/uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java b/uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java
index f6bb4d93f7..ce62ddd4be 100644
--- a/uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java
+++ b/uitest-common/src/main/java/com/vaadin/testbench/customelements/RadioButtonGroupElement.java
@@ -15,55 +15,23 @@
*/
package com.vaadin.testbench.customelements;
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elements.AbstractSelectElement;
-import com.vaadin.testbench.elementsbase.ServerClass;
-import org.openqa.selenium.WebElement;
-
import java.util.ArrayList;
import java.util.List;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+
/**
* TestBench element supporting RadioButtonGroup
*
* @author Vaadin Ltd
*/
-@ServerClass("com.vaadin.ui.RadioButtonGroup")
-public class RadioButtonGroupElement extends AbstractSelectElement {
+public class RadioButtonGroupElement
+ extends com.vaadin.testbench.elements.RadioButtonGroupElement {
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<>();
- List<WebElement> options = findElements(byButtonSpan);
- for (WebElement option : options) {
- optionTexts.add(option.findElement(byLabel).getText());
- }
- return optionTexts;
- }
-
- public void selectByText(String text) throws ReadOnlyException {
- if (isReadOnly()) {
- throw new ReadOnlyException();
- }
- List<WebElement> options = findElements(byButtonSpan);
- 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);
- }
- }
- }
/**
* Return list of the selected options in the radiobutton group