summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-06-18 11:28:14 +0300
committerVaadin Code Review <review@vaadin.com>2014-06-18 10:02:16 +0000
commit7de2808b04dcf10628b7952251d834d38925dfa4 (patch)
tree1e2b05de02ee066ce220804aff93dae66c78e981 /uitest/src/com
parent5981b6e6b693eb2a4166c1954f96ab0f93c7f744 (diff)
downloadvaadin-framework-7de2808b04dcf10628b7952251d834d38925dfa4.tar.gz
vaadin-framework-7de2808b04dcf10628b7952251d834d38925dfa4.zip
Refactor CheckBoxRcpCountTest to be more stable.
Change-Id: Icc1965e6bc23423d8af66ab91b80143d07b49483
Diffstat (limited to 'uitest/src/com')
-rw-r--r--uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java
index c32051b593..9d6640eb6d 100644
--- a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java
+++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCountTest.java
@@ -17,34 +17,47 @@ package com.vaadin.tests.components.checkbox;
import static org.junit.Assert.assertEquals;
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.testbench.elements.LabelElement;
import org.junit.Test;
import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.openqa.selenium.support.ui.ExpectedCondition;
public class CheckBoxRpcCountTest extends MultiBrowserTest {
@Test
- public void testNumberOfRpcCalls() {
+ public void numberOfRpcCallsIsEqualToClicks() {
openTestURL();
- WebElement labelElem = driver.findElement(By
- .cssSelector(".v-checkbox label"));
- WebElement inputElem = driver.findElement(By
- .cssSelector(".v-checkbox input"));
- WebElement countElem = driver.findElement(By.id("count-label"));
+ CheckBoxElement checkBoxElement = $(CheckBoxElement.class).first();
+ WebElement labelElem = checkBoxElement.findElement(By.tagName("label"));
+ WebElement inputElem = checkBoxElement.findElement(By.tagName("input"));
+ final WebElement countElem = $(LabelElement.class).id("count-label");
// Click on the actual checkbox.
inputElem.click();
- assertEquals("1 RPC call(s) made.", countElem.getText());
+ //Have to use waitUntil to make this test more stable.
+ waitUntilLabelIsUpdated(countElem, "1 RPC call(s) made.");
// Click on the checkbox label.
labelElem.click();
- assertEquals("2 RPC call(s) made.", countElem.getText());
+ waitUntilLabelIsUpdated(countElem, "2 RPC call(s) made.");
// Again on the label.
labelElem.click();
- assertEquals("3 RPC call(s) made.", countElem.getText());
+ waitUntilLabelIsUpdated(countElem, "3 RPC call(s) made.");
+ }
+
+ private void waitUntilLabelIsUpdated(final WebElement countElem, final String expectedText) {
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver input) {
+ return countElem.getText().equals(expectedText);
+ }
+ }, 5);
}
}