From 29d4fb1090756d5c58ba52fc43c43891c7e5beed Mon Sep 17 00:00:00 2001 From: caalador Date: Fri, 10 Sep 2021 15:06:57 +0300 Subject: [PATCH] test: Fix expectation on windows (#11808) Windows receives a different error string so we need to check the target os when running the test. Fixes #11777 --- .../uitest/ui/ClientSideExceptionHandlingIT.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/ClientSideExceptionHandlingIT.java b/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/ClientSideExceptionHandlingIT.java index e043353cad4..37f608255de 100644 --- a/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/ClientSideExceptionHandlingIT.java +++ b/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/ClientSideExceptionHandlingIT.java @@ -20,12 +20,15 @@ import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; import com.vaadin.flow.testutil.ChromeBrowserTest; public class ClientSideExceptionHandlingIT extends ChromeBrowserTest { private static final By ERROR_LOCATOR = By.className("v-system-error"); + public static final String UNIX_PATTERN = ".*TypeError.* property 'foo' of.*null.*"; + public static final String WINDOWS_PATTERN = ".*TypeError.* : Cannot read properties of null .*reading 'foo'.*"; @Test public void developmentModeExceptions() { @@ -34,9 +37,14 @@ public void developmentModeExceptions() { String errorMessage = findElement(ERROR_LOCATOR).getText(); + // Windows formats the error differently from unix + final boolean isWindows = (boolean) ((JavascriptExecutor) getDriver()) + .executeScript( + "return navigator.appVersion.indexOf(\"Win\")!=-1"); + String testPattern = isWindows ? WINDOWS_PATTERN : UNIX_PATTERN; + Assert.assertTrue("Unexpected error message: " + errorMessage, - Pattern.matches(".*TypeError.* property 'foo' of.*null.*", - errorMessage)); + Pattern.matches(testPattern, errorMessage)); } @Test