summaryrefslogtreecommitdiffstats
path: root/uitest/src/com
diff options
context:
space:
mode:
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);
}
}