diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-13 15:10:20 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-10-13 16:10:20 +0300 |
commit | e651d542cbef31cfc09786e1978e33915cb68a27 (patch) | |
tree | e884b448f5037c2a1d438b7d2ad704328ccaeffc /uitest | |
parent | dd5597d9014032cc366d4b70405e007b1876c350 (diff) | |
download | vaadin-framework-e651d542cbef31cfc09786e1978e33915cb68a27.tar.gz vaadin-framework-e651d542cbef31cfc09786e1978e33915cb68a27.zip |
Simplify waitUntil() in tests (#10181)
Diffstat (limited to 'uitest')
23 files changed, 58 insertions, 200 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java index 121abd505e..7f4b940bc3 100644 --- a/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java +++ b/uitest/src/test/java/com/vaadin/tests/application/ReconnectDialogThemeTest.java @@ -52,14 +52,7 @@ public class ReconnectDialogThemeTest extends MultiBrowserThemeTestWithProxy { disconnectProxy(); helloButton.click(); testBench().disableWaitForVaadin(); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - boolean present = isElementPresent(reconnectDialogBy); - return present; - } - }); + waitUntil(driver -> isElementPresent(reconnectDialogBy)); WebElement dialog = findElement(reconnectDialogBy); WebElement spinner = dialog.findElement(By.className("spinner")); diff --git a/uitest/src/test/java/com/vaadin/tests/components/NoLayoutUpdateWhichNeedsLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/NoLayoutUpdateWhichNeedsLayoutTest.java index cd8b6f86d0..48093b6b42 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/NoLayoutUpdateWhichNeedsLayoutTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/NoLayoutUpdateWhichNeedsLayoutTest.java @@ -16,11 +16,9 @@ package com.vaadin.tests.components; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; -import com.vaadin.testbench.elements.ProgressBarElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.ProgressBarElement; import com.vaadin.tests.tb3.SingleBrowserTest; public class NoLayoutUpdateWhichNeedsLayoutTest extends SingleBrowserTest { @@ -31,12 +29,9 @@ public class NoLayoutUpdateWhichNeedsLayoutTest extends SingleBrowserTest { ButtonElement open = $(ButtonElement.class).id("openWindow"); open.click(); final ProgressBarElement progress = $(ProgressBarElement.class).first(); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - double p = progress.getValue(); - return Math.abs(p - 0.5) < 0.01; - } + waitUntil(driver -> { + double p = progress.getValue(); + return Math.abs(p - 0.5) < 0.01; }); ButtonElement close = $(ButtonElement.class).id("closeWindow"); diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java index 88e465cbee..5217dd6f0f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSlowTest.java @@ -23,10 +23,8 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -73,13 +71,10 @@ public class ComboBoxSlowTest extends MultiBrowserTest { assertTrue(isPagingActive()); goToNextPage(); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - List<WebElement> filteredItems = getFilteredItems(popup); - return filteredItems.size() == 1 - && "Item 129".equals(filteredItems.get(0).getText()); - } + waitUntil(input -> { + List<WebElement> items = getFilteredItems(popup); + return items.size() == 1 + && "Item 129".equals(items.get(0).getText()); }); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldStatesTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldStatesTest.java index 7d642faf70..fd325f8ad6 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldStatesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldStatesTest.java @@ -20,10 +20,8 @@ public class PopupDateFieldStatesTest extends MultiBrowserTest { WebElement loadingIndicator = findElement( By.className("v-loading-indicator")); Pattern pattern = Pattern.compile("display: *none;"); - waitUntil(driver -> { - return pattern.matcher(loadingIndicator.getAttribute("style")) - .find(); - }); + waitUntil(driver -> pattern + .matcher(loadingIndicator.getAttribute("style")).find()); compareScreen("dateFieldStates"); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateTimeFieldStatesTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateTimeFieldStatesTest.java index bd97b6342b..fda31a3928 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateTimeFieldStatesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateTimeFieldStatesTest.java @@ -20,10 +20,8 @@ public class PopupDateTimeFieldStatesTest extends MultiBrowserTest { WebElement loadingIndicator = findElement( By.className("v-loading-indicator")); Pattern pattern = Pattern.compile("display: *none;"); - waitUntil(driver -> { - return pattern.matcher(loadingIndicator.getAttribute("style")) - .find(); - }); + waitUntil(driver -> pattern + .matcher(loadingIndicator.getAttribute("style")).find()); compareScreen("dateFieldStates"); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java index b5ff8a33b4..6f4c9bfbfa 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/AbstractGridColumnAutoWidthTest.java @@ -97,10 +97,8 @@ public abstract class AbstractGridColumnAutoWidthTest extends MultiBrowserTest { WebElement loadingIndicator = findElement( By.className("v-loading-indicator")); Pattern pattern = Pattern.compile("display: *none;"); - waitUntil(driver -> { - return pattern.matcher(loadingIndicator.getAttribute("style")) - .find(); - }); + waitUntil(driver -> pattern + .matcher(loadingIndicator.getAttribute("style")).find()); compareScreen("grid-v8-initialRender"); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java index 0b5b5f10ee..9787b818c4 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDownTest.java @@ -4,9 +4,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.testbench.TestBenchElement; @@ -24,14 +22,8 @@ public class GridApplyFilterWhenScrolledDownTest extends MultiBrowserTest { $(ButtonElement.class).first().click(); final TestBenchElement gridBody = grid.getBody(); // Can't use element API because it scrolls - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return gridBody.findElements(By.className("v-grid-row")) - .size() == 1; - } - }); + waitUntil(input -> gridBody.findElements(By.className("v-grid-row")) + .size() == 1); WebElement cell = gridBody.findElements(By.className("v-grid-cell")) .get(0); assertEquals("Test", cell.getText()); diff --git a/uitest/src/test/java/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java b/uitest/src/test/java/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java index e2d09f1773..02d1b36167 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/layout/EmptySpaceOnPageAfterExpandedComponentTest.java @@ -16,9 +16,7 @@ package com.vaadin.tests.components.layout; import org.junit.Test; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -46,16 +44,13 @@ public class EmptySpaceOnPageAfterExpandedComponentTest final WebElement expandedElement = vaadinElementById("expandedElement"); final WebElement containerElement = vaadinElementById("container"); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - int expandedElementBottom = expandedElement.getLocation().getY() - + expandedElement.getSize().getHeight(); - int containerElementBottom = containerElement.getLocation() - .getY() + containerElement.getSize().getHeight(); + waitUntil(input -> { + int expandedElementBottom = expandedElement.getLocation().getY() + + expandedElement.getSize().getHeight(); + int containerElementBottom = containerElement.getLocation().getY() + + containerElement.getSize().getHeight(); - return expandedElementBottom + 1 == containerElementBottom; - } + return expandedElementBottom + 1 == containerElementBottom; }); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationDelayTest.java b/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationDelayTest.java index e2cc28db7d..eb3077d514 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationDelayTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/notification/NotificationDelayTest.java @@ -19,9 +19,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -38,14 +36,10 @@ public class NotificationDelayTest extends MultiBrowserTest { assertTrue("No notification found", hasNotification()); - waitUntil(new ExpectedCondition<Boolean>() { + waitUntil(input -> { + new Actions(getDriver()).moveByOffset(10, 10).perform(); - @Override - public Boolean apply(WebDriver input) { - new Actions(getDriver()).moveByOffset(10, 10).perform(); - - return !hasNotification(); - } + return !hasNotification(); }); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java index 8188b0dfdb..e995700afc 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/HeaderRightClickAfterDragTest.java @@ -17,9 +17,7 @@ package com.vaadin.tests.components.table; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.elements.TableElement; @@ -62,11 +60,6 @@ public class HeaderRightClickAfterDragTest extends MultiBrowserTest { private void closeWindow() { WindowElement window = $(WindowElement.class).first(); window.findElement(By.className("v-window-closebox")).click(); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver driver) { - return findElements(By.className("v-window")).isEmpty(); - } - }); + waitUntil(input -> findElements(By.className("v-window")).isEmpty()); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java index c4d60de804..e81e21c494 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java @@ -21,13 +21,11 @@ import java.util.List; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.ui.ExpectedCondition; -import com.vaadin.testbench.elements.TableElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; import com.vaadin.tests.tb3.MultiBrowserTest; /** @@ -65,12 +63,7 @@ public class TableColumnResizeContentsWidthTest extends MultiBrowserTest { } private void waitUntilTextFieldWidthIs(final int width) { - waitUntil(new ExpectedCondition<Object>() { - @Override - public Object apply(WebDriver input) { - return getTextFieldWidth() == width; - } - }); + waitUntil(input -> getTextFieldWidth() == width); } private int getTextFieldWidth() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaSizeResettedTest.java b/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaSizeResettedTest.java index a3530f69af..e288636815 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaSizeResettedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textarea/TextAreaSizeResettedTest.java @@ -9,10 +9,8 @@ import java.util.List; import org.junit.Test; import org.openqa.selenium.Dimension; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.LabelElement; @@ -98,12 +96,7 @@ public class TextAreaSizeResettedTest extends MultiBrowserTest { private void waitUntilPollingOccurs() { final String timestamp = getPollTimestamp(); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return !timestamp.equals(getPollTimestamp()); - } - }); + waitUntil(input -> !timestamp.equals(getPollTimestamp())); } private String getPollTimestamp() { diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseExpandTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseExpandTest.java index 59ff75ecd0..038d51d7c0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseExpandTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridCollapseExpandTest.java @@ -3,8 +3,6 @@ package com.vaadin.tests.components.treegrid; import static org.junit.Assert.assertEquals; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.TreeGridElement; import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; @@ -52,11 +50,6 @@ public class TreeGridCollapseExpandTest extends SingleBrowserTestPhantomJS2 { } private void waitUntilRowCountEquals(int expectedCount) { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return grid.getRowCount() == expectedCount; - } - }); + waitUntil(input -> grid.getRowCount() == expectedCount); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/PushStateAndReplaceStateTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/PushStateAndReplaceStateTest.java index 159967af2a..9991eb313b 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/PushStateAndReplaceStateTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/PushStateAndReplaceStateTest.java @@ -5,8 +5,6 @@ import static org.junit.Assert.assertEquals; import java.net.URI; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -50,13 +48,7 @@ public class PushStateAndReplaceStateTest extends MultiBrowserTest { private void assertUri(String uri) { final String expectedText = "Current Location: " + uri; - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return expectedText.equals(getLocationLabelValue()); - } - }); + waitUntil(input -> expectedText.equals(getLocationLabelValue())); assertEquals(uri, driver.getCurrentUrl()); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java index d73696144d..f263dd7069 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UIAccessTest.java @@ -18,8 +18,6 @@ package com.vaadin.tests.components.ui; import static org.junit.Assert.assertTrue; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -69,12 +67,7 @@ public class UIAccessTest extends MultiBrowserTest { } private void waitForLogToContainText(final String text) { - waitUntil(new ExpectedCondition<Object>() { - @Override - public Object apply(WebDriver input) { - return logContainsText(text); - } - }); + waitUntil(input -> logContainsText(text)); } @Test diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/UriFragmentTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/UriFragmentTest.java index 731573b770..1556355149 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/UriFragmentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/UriFragmentTest.java @@ -4,8 +4,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -53,14 +51,7 @@ public class UriFragmentTest extends MultiBrowserTest { private void assertFragment(String fragment) { final String expectedText = "Current URI fragment: " + fragment; - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return expectedText.equals(getFragmentLabelValue()); - } - }); - + waitUntil(input -> expectedText.equals(getFragmentLabelValue())); } private void navigateToEmptyFragment() { diff --git a/uitest/src/test/java/com/vaadin/tests/extensions/ResponsiveLayoutUpdateTest.java b/uitest/src/test/java/com/vaadin/tests/extensions/ResponsiveLayoutUpdateTest.java index 29b40de764..412c6e8079 100644 --- a/uitest/src/test/java/com/vaadin/tests/extensions/ResponsiveLayoutUpdateTest.java +++ b/uitest/src/test/java/com/vaadin/tests/extensions/ResponsiveLayoutUpdateTest.java @@ -17,8 +17,6 @@ package com.vaadin.tests.extensions; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.testbench.elements.PanelElement; @@ -41,12 +39,7 @@ public class ResponsiveLayoutUpdateTest extends MultiBrowserTest { // Resize below 600px width breakpoint testBench().resizeViewPortTo(400, 768); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return panelElement.getSize().getWidth() < 500; - } - }); + waitUntil(input -> panelElement.getSize().getWidth() < 500); compareScreen("small"); } } diff --git a/uitest/src/test/java/com/vaadin/tests/push/PushConfigurationTest.java b/uitest/src/test/java/com/vaadin/tests/push/PushConfigurationTest.java index 255b69947e..d6eba09342 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/PushConfigurationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/PushConfigurationTest.java @@ -17,9 +17,7 @@ package com.vaadin.tests.push; import static org.junit.Assert.assertEquals; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.elements.NativeSelectElement; import com.vaadin.testbench.parallel.TestCategory; @@ -77,12 +75,6 @@ abstract class PushConfigurationTest extends MultiBrowserTest { protected void waitForServerCounterToUpdate() { int counter = getServerCounter(); final int waitCounter = counter + 2; - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return (getServerCounter() >= waitCounter); - } - }); + waitUntil(input -> getServerCounter() >= waitCounter); } } diff --git a/uitest/src/test/java/com/vaadin/tests/push/PushFromInitTest.java b/uitest/src/test/java/com/vaadin/tests/push/PushFromInitTest.java index d877dcb2d3..0a77f8c548 100644 --- a/uitest/src/test/java/com/vaadin/tests/push/PushFromInitTest.java +++ b/uitest/src/test/java/com/vaadin/tests/push/PushFromInitTest.java @@ -16,8 +16,6 @@ package com.vaadin.tests.push; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.parallel.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -28,13 +26,8 @@ public class PushFromInitTest extends MultiBrowserTest { public void testPushFromInit() { openTestURL(); - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return ("3. " + PushFromInit.LOG_AFTER_INIT) - .equals(getLogRow(0)); - } - }); + waitUntil(input -> ("3. " + PushFromInit.LOG_AFTER_INIT) + .equals(getLogRow(0))); } } diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java index 3b3ab94e86..dccf8e3742 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -470,12 +470,7 @@ public abstract class AbstractTB3Test extends ParallelTest { } protected void waitForElementNotPresent(final By by) { - waitUntil(new ExpectedCondition<Boolean>() { - @Override - public Boolean apply(WebDriver input) { - return input.findElements(by).isEmpty(); - } - }); + waitUntil(input -> input.findElements(by).isEmpty()); } protected void waitForElementVisible(final By by) { diff --git a/uitest/src/test/java/com/vaadin/tests/urifragments/SettingNullFragmentTest.java b/uitest/src/test/java/com/vaadin/tests/urifragments/SettingNullFragmentTest.java index f728be937a..f2cc1a54c1 100644 --- a/uitest/src/test/java/com/vaadin/tests/urifragments/SettingNullFragmentTest.java +++ b/uitest/src/test/java/com/vaadin/tests/urifragments/SettingNullFragmentTest.java @@ -18,9 +18,7 @@ package com.vaadin.tests.urifragments; import java.util.List; import org.junit.Test; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -54,17 +52,13 @@ public class SettingNullFragmentTest extends MultiBrowserTest { private void assertFragment(String fragment) { final String expectedText = fragment; - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - String currentURL = getDriver().getCurrentUrl(); - String currentURIFragment = ""; - if (currentURL.contains("#") && !currentURL.endsWith("#")) { - currentURIFragment = currentURL.split("#")[1]; - } - return expectedText.equals(currentURIFragment); + waitUntil(input -> { + String currentURL = getDriver().getCurrentUrl(); + String currentURIFragment = ""; + if (currentURL.contains("#") && !currentURL.endsWith("#")) { + currentURIFragment = currentURL.split("#")[1]; } + return expectedText.equals(currentURIFragment); }); } diff --git a/uitest/src/test/java/com/vaadin/tests/widgetset/server/csrf/ui/AbstractCsrfTokenUITest.java b/uitest/src/test/java/com/vaadin/tests/widgetset/server/csrf/ui/AbstractCsrfTokenUITest.java index f52ed03c31..7fd76d9b2e 100644 --- a/uitest/src/test/java/com/vaadin/tests/widgetset/server/csrf/ui/AbstractCsrfTokenUITest.java +++ b/uitest/src/test/java/com/vaadin/tests/widgetset/server/csrf/ui/AbstractCsrfTokenUITest.java @@ -21,8 +21,6 @@ import java.util.logging.Logger; import org.junit.Test; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.widgetset.client.csrf.CsrfButtonConnector; @@ -43,27 +41,22 @@ public abstract class AbstractCsrfTokenUITest extends MultiBrowserTest { getDriver().findElement(By.id(CsrfTokenDisabled.PRESS_ID)).click(); - waitUntil(new ExpectedCondition<Boolean>() { + waitUntil(input -> { + getDriver().findElement(debugButton).click(); + String debugMessage2 = input.findElement(debugButton).getText(); - @Override - public Boolean apply(WebDriver input) { - getDriver().findElement(debugButton).click(); - String debugMessage2 = input.findElement(debugButton).getText(); + LOGGER.log(Level.INFO, "1: " + debugMessage1); + LOGGER.log(Level.INFO, "2: " + debugMessage2); - LOGGER.log(Level.INFO, "1: " + debugMessage1); - LOGGER.log(Level.INFO, "2: " + debugMessage2); + if (!debugMessage1.equals(debugMessage2)) { - if (!debugMessage1.equals(debugMessage2)) { + compareMessage(split(debugMessage1), split(debugMessage2)); - compareMessage(split(debugMessage1), split(debugMessage2)); + LOGGER.log(Level.INFO, "DONE"); - LOGGER.log(Level.INFO, "DONE"); - - return true; - - } else { - return false; - } + return true; + } else { + return false; } }); } diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDisabledSideBarTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDisabledSideBarTest.java index 390b4a801b..3eb0b9ffd3 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDisabledSideBarTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/GridDisabledSideBarTest.java @@ -4,8 +4,6 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.testbench.By; import com.vaadin.v7.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; @@ -25,14 +23,8 @@ public class GridDisabledSideBarTest extends GridBasicClientFeaturesTest { private void toggleSideBarMenuAndDisable() { selectMenuPath("Component", "Sidebar", "Open sidebar and disable grid"); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - return !findElement(By.className("v-grid-sidebar-button")) - .isEnabled(); - } - }); + waitUntil(input -> !findElement(By.className("v-grid-sidebar-button")) + .isEnabled()); } private void clickSideBarButton() { |