如何通过脚本以编程方式确定已安装的 IE 版本
我们有一个基于selenium-grid的自动化测试集群。
为了管理集群,我构建了一个 Rake (Ruby) 任务集合,可以启动、重新启动、ping 和停止节点。我正在多种浏览器(包括 IE6、IE7 和 IE8)上测试我们的应用程序。这意味着集群中的每个节点都必须知道安装了哪个版本的 IE,以便它可以声明正确的 selenium-grid 配置文件名称(例如:“Windows XP 上的 IE6”
与 “Windows Vista 上的 IE8”
),以便可以针对这些浏览器编写某些测试。
我的问题:
我想减少这里的配置工作。如何以编程方式确定当前系统上运行的 IE 版本?我尝试了以下技术:
wmic product where "Vendor like '%Microsoft%'" get Name, Version
但这仅返回使用 Windows Installer 安装的程序的版本,因此 IE 不会显示在此列表中。
理想情况下,我希望能够从 Rake 脚本内部确定这一点,或者至少是可以从 Rake 脚本调用的东西。
We have an automated testing cluster based on selenium-grid.
To manage the cluster, I have built a collection of Rake (Ruby) tasks which can start, restart, ping, and stop nodes. I'm testing our application across a number of browsers including IE6, IE7, and IE8. This means each node in the cluster has to be aware of which version of IE is installed so that it can claim the correct selenium-grid profile name (eg: "IE6 on Windows XP"
vs. "IE8 on Windows Vista"
), so that certain tests can be written against those browsers.
My question:
I'd like to cut down on the configuration work here. How do I programmatically determine which version of IE is running on the current system? I have tried the following technique:
wmic product where "Vendor like '%Microsoft%'" get Name, Version
But this only returns versions of programs that were installed with the Windows Installer, so IE doesn't show up in this list.
Ideally I'd like to be able to determine this from inside of a Rake script, or at least something that's callable from a Rake script.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 WMI,我知道它不是 rake 脚本,但您可以运行该脚本(或创建 .NET 应用程序)并将结果输入到您的应用程序中。
这有点像黑客,但至少它会起作用。这是来自 technet 的一些代码。
完整 来源
获得此信息后,您可以使用命令行将该信息传递到您的 rake 脚本。
编辑:您可以将此代码复制/粘贴到文件中,将其命名为whatever.vbs,然后使用cscript命令来执行脚本。
You can use WMI, I know it's not a rake script, but you could run the script (or create a .NET application) and feed the results into your application.
It's kind of a hack, but at least it will work. Here's some code from technet.
Full Source
Once you have this information, you can pass the information to your rake script using the command line.
EDIT: You can copy/paste this code into a file, name it whatever.vbs, and use the cscript command to execute the script.
在任何版本的 Windows 上尝试此操作:
Try this for any version of Windows:
当我安装了 11.X 时,注册表中的“版本”字段似乎显示其为 9.X,但“svcVersion”显示的版本与 IE11 的“关于”框中显示的版本相同,所以也许
是更好的选择?
the "Version" field in the registry seems to say its 9.X when I have 11.X installed, but the "svcVersion" shows the same version that displays in the about box of IE11 so perhaps
is a better choice?