views:

247

answers:

1

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.

+2  A: 

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

Robert Greiner
Awesome, this appears to work, however Wscript.Echo outputs to a window. Is there an easy way to output to stdout ?
Maciek
see edits, is that what you want?
Robert Greiner
Thanks! I poked around with cscript options and also added //Nologo to omit MS's copyright message.
Maciek
Perfect! I'm glad you got what you needed. It's nice when things work out so well.
Robert Greiner
one final edit to answer for completeness.
Robert Greiner
To keep stuff pure Ruby, you can try using ruby-wmi - http://ruby-wmi.rubyforge.org/
kejadlen
A bump in the road: the script works under XP, but not under Vista. Perhaps IE is registered differently under Vista?
Maciek