Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the WebDriver version during Testrun?

I am writing on a testframework where the report should include the webdriver version of the test run. When using selenium there is the getEval("Selenium.version") method. But I find no way to read the version when using webdriver. Does anyone know a solution?

like image 426
theBell Avatar asked Nov 22 '25 19:11

theBell


1 Answers

It's possible by reading the VERSION.txt properties file. This seems hacky, but it's what the WebDriver developers do in SeleniumServer.java:

final Properties p = new Properties();
p.load(getSeleniumResourceAsStream("/VERSION.txt"));
String rcVersion = p.getProperty("selenium.rc.version");
String rcRevision = p.getProperty("selenium.rc.revision");
String coreVersion = p.getProperty("selenium.core.version");
String coreRevision = p.getProperty("selenium.core.revision");
BuildInfo info = new BuildInfo();
String versionString = String.format("v%s%s, with Core v%s%s. Built from revision %s",
    rcVersion, rcRevision, coreVersion, coreRevision, info.getBuildRevision());

Note that this requires a static import:

import static org.openqa.selenium.browserlaunchers.LauncherUtils.getSeleniumResourceAsStream;

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!