From d17a15be0a38955a1e5187c36dc2dc3b59d27a02 Mon Sep 17 00:00:00 2001 From: Guille Date: Wed, 15 Nov 2017 11:15:34 +0200 Subject: [PATCH] Add a runtime check that the expected Selenium version is found (#962) Originally implemented in #961 --- .../vaadin/testbench/TestBenchTestCase.java | 28 +++++++++++++++++++ .../com/vaadin/testbench/testbench.properties | 1 + 2 files changed, 29 insertions(+) create mode 100644 vaadin-testbench-core/src/main/resources/com/vaadin/testbench/testbench.properties diff --git a/vaadin-testbench-core/src/main/java/com/vaadin/testbench/TestBenchTestCase.java b/vaadin-testbench-core/src/main/java/com/vaadin/testbench/TestBenchTestCase.java index 816bf7b27..96f61112d 100644 --- a/vaadin-testbench-core/src/main/java/com/vaadin/testbench/TestBenchTestCase.java +++ b/vaadin-testbench-core/src/main/java/com/vaadin/testbench/TestBenchTestCase.java @@ -13,6 +13,9 @@ package com.vaadin.testbench; import java.util.List; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; import org.junit.Rule; import org.openqa.selenium.JavascriptExecutor; @@ -21,6 +24,7 @@ import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.internal.BuildInfo; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.FluentWait; import org.openqa.selenium.support.ui.WebDriverWait; @@ -44,6 +48,30 @@ public abstract class TestBenchTestCase LicenseChecker.nag(); } + static { + try { + String seleniumVersion = new BuildInfo().getReleaseLabel(); + + Properties properties = new Properties(); + properties.load(TestBenchTestCase.class + .getResourceAsStream("testbench.properties")); + String expectedVersion = properties.getProperty("selenium.version"); + if (seleniumVersion == null + || !seleniumVersion.equals(expectedVersion)) { + Logger.getLogger(TestBenchTestCase.class.getName()).warning( + "This version of TestBench depends on Selenium version " + + expectedVersion + " but version " + + seleniumVersion + + " was found. Make sure you do not have multiple versions of Selenium on the classpath."); + } + } catch (Exception e) { + Logger.getLogger(TestBenchTestCase.class.getName()).log( + Level.WARNING, + "Unable to validate that the correct Selenium version is in use", + e); + } + } + /** * Specifies retry count, which is used to run same test several times. Can * be changed by setting "com.vaadin.testbench.Parameters.maxAttempts" diff --git a/vaadin-testbench-core/src/main/resources/com/vaadin/testbench/testbench.properties b/vaadin-testbench-core/src/main/resources/com/vaadin/testbench/testbench.properties new file mode 100644 index 000000000..3f135f66d --- /dev/null +++ b/vaadin-testbench-core/src/main/resources/com/vaadin/testbench/testbench.properties @@ -0,0 +1 @@ +selenium.version=${selenium.version} \ No newline at end of file