aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2019-12-20 11:18:03 +0200
committerOlli Tietäväinen <ollit@vaadin.com>2019-12-20 11:18:03 +0200
commit685e4487932f53890057d1e9a69f3d2e484eb0bd (patch)
tree782bffde6d2db0eac08fca3b1721dca01035d718 /uitest
parent35883e01bcbaf5ba2f5728ea1ad03fe3eb359c5d (diff)
downloadvaadin-framework-685e4487932f53890057d1e9a69f3d2e484eb0bd.tar.gz
vaadin-framework-685e4487932f53890057d1e9a69f3d2e484eb0bd.zip
Test tweaks (#11851)
* Test tweaks Less fixed waiting times when there are ways to check that the operation has been performed. This will hopefully improve the stability a bit. * Merge branch 'master' into updateTests20191218
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java2
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java48
2 files changed, 28 insertions, 22 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java
index 34ef8847c2..23a747c4ea 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java
@@ -22,7 +22,7 @@ public class GridEditorFrozenColumnsUITest extends MultiBrowserTest {
openTestURL();
openEditor(10);
- sleep(500);
+ waitForElementPresent(By.className("v-grid-editor"));
compareScreen("noscroll");
scrollGridHorizontallyTo(100);
diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java
index 8e1d0ba7b3..3d791bd4b8 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java
@@ -7,19 +7,19 @@ import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.By;
-import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.internal.WrapsElement;
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebElement;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.WindowElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.tests.util.LoremIpsum;
-import static org.junit.Assert.assertTrue;
-
public class InterruptUploadTest extends MultiBrowserTest {
private static final String EXPECTED_COUNTER_TEXT = " (counting interrupted at ";
@@ -29,36 +29,42 @@ public class InterruptUploadTest extends MultiBrowserTest {
openTestURL();
File tempFile = createTempFile();
- scheduleUploadCancel();
-
fillPathToUploadInput(tempFile.getPath());
- // Wait for 3 seconds until everything is done.
- Thread.sleep(3000);
-
- String actual = $(LabelElement.class).caption("Line breaks counted")
- .first().getText();
- assertTrue("Line break count note does not match expected (was: "
- + actual + ")", actual.contains(EXPECTED_COUNTER_TEXT));
+ waitForElementPresent(By.className("v-window"));
+ $(ButtonElement.class).caption("Cancel").first().click();
+ waitUntilInterruptionRegistered();
$(WindowElement.class).first().close();
waitForElementNotPresent(By.className("v-window"));
// Check if second upload happens
tempFile = createTempFile();
- scheduleUploadCancel();
fillPathToUploadInput(tempFile.getPath());
- actual = $(LabelElement.class).caption("Line breaks counted").first()
- .getText();
- assertTrue("Line break count note does not match expected (was: "
- + actual + ")", actual.contains(EXPECTED_COUNTER_TEXT));
+ waitForElementPresent(By.className("v-window"));
+ $(ButtonElement.class).caption("Cancel").first().click();
+ waitUntilInterruptionRegistered();
}
- private void scheduleUploadCancel() {
- // Schedule upload cancel in 2 seconds
- ((JavascriptExecutor) getDriver()).executeScript(
- "setTimeout( function () {window.document.querySelector(\".v-window .v-button\").click()},2000)");
+ private void waitUntilInterruptionRegistered() {
+ waitUntil(new ExpectedCondition<Boolean>() {
+ String actual;
+
+ @Override
+ public Boolean apply(WebDriver arg0) {
+ actual = $(LabelElement.class).caption("Line breaks counted")
+ .first().getText();
+ return actual.contains(EXPECTED_COUNTER_TEXT);
+ }
+
+ @Override
+ public String toString() {
+ // Expected condition failed: waiting for ...
+ return "line break count note to mention interruption (was: "
+ + actual + ")";
+ }
+ });
}
/**