在Testrun期间如何获取WebDriver版本? [英] How can I get the WebDriver version during Testrun?

查看:56
本文介绍了在Testrun期间如何获取WebDriver版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个测试框架,其中报告应包括测试运行的网络驱动程序版本.使用硒时,有getEval("Selenium.version")方法.但是我发现使用webdriver时无法读取版本.有人知道解决方案吗?

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?

推荐答案

可以通过读取VERSION.txt属性文件来实现.这似乎很棘手,但这是WebDriver开发人员在SeleniumServer.java中所做的:

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;

这篇关于在Testrun期间如何获取WebDriver版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆