如何通过脚本以编程方式确定已安装的 IE 版本

发布于 2024-08-18 23:22:53 字数 584 浏览 4 评论 0原文

我们有一个基于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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

听你说爱我 2024-08-25 23:22:53

您可以使用 WMI,我知道它不是 rake 脚本,但您可以运行该脚本(或创建 .NET 应用程序)并将结果输入到您的应用程序中。

这有点像黑客,但至少它会起作用。这是来自 technet 的一些代码。

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & _
    "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_Summary")

For Each strIESetting in colIESettings
    Wscript.Echo strIESetting.Version
Next

完整 来源

获得此信息后,您可以使用命令行将该信息传递到您的 rake 脚本。

rake YourScript[<argument from vbscript>]

编辑:您可以将此代码复制/粘贴到文件中,将其命名为whatever.vbs,然后使用cscript命令来执行脚本。

cscript //Nologo ie_version.vbs

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.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & _
    "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_Summary")

For Each strIESetting in colIESettings
    Wscript.Echo strIESetting.Version
Next

Full Source

Once you have this information, you can pass the information to your rake script using the command line.

rake YourScript[<argument from vbscript>]

EDIT: You can copy/paste this code into a file, name it whatever.vbs, and use the cscript command to execute the script.

cscript //Nologo ie_version.vbs

淡淡離愁欲言轉身 2024-08-25 23:22:53

在任何版本的 Windows 上尝试此操作:

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Internet Explorer"

strValueName = "Version"

oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

Wscript.Echo "Installed IE Version: " & strValue

Wscript.Echo "IE Version: " & Left(strValue,1)

Try this for any version of Windows:

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Internet Explorer"

strValueName = "Version"

oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

Wscript.Echo "Installed IE Version: " & strValue

Wscript.Echo "IE Version: " & Left(strValue,1)
自找没趣 2024-08-25 23:22:53

当我安装了 11.X 时,注册表中的“版本”字段似乎显示其为 9.X,但“svcVersion”显示的版本与 IE11 的“关于”框中显示的版本相同,所以也许

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\svcVersion

是更好的选择?

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

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\svcVersion

is a better choice?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文