Browse Source

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
tags/8.10.0.beta1
Anna Koskinen 4 years ago
parent
commit
685e448793

+ 1
- 1
uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorFrozenColumnsUITest.java View File

@@ -22,7 +22,7 @@ public class GridEditorFrozenColumnsUITest extends MultiBrowserTest {
openTestURL();

openEditor(10);
sleep(500);
waitForElementPresent(By.className("v-grid-editor"));
compareScreen("noscroll");

scrollGridHorizontallyTo(100);

+ 27
- 21
uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java View File

@@ -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 + ")";
}
});
}

/**

Loading…
Cancel
Save