Skip to content

Commit

Permalink
Add a runtime check that the expected Selenium version is found (#962)
Browse files Browse the repository at this point in the history
Originally implemented in #961
  • Loading branch information
alvarezguille authored Nov 15, 2017
1 parent 1458319 commit d17a15b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
selenium.version=${selenium.version}

0 comments on commit d17a15b

Please sign in to comment.