Using the Windows api, I came up with this quick hack which may or may not have much merit :) :
require "Win32API" GetVersionEx = Win32API.new("kernel32", "GetVersionEx", 'P', 'L') def system_version osversioninfo = [ 148, # size of this struct (IN) 0, # major version (OUT) 0, # minor version (OUT) 0, # build (OUT) 0, # platform (OUT) "\0" * 128 # additional info (OUT) ].pack('LLLLLa128') GetVersionEx.call(osversioninfo) osver = osversioninfo.unpack('LLLLLZ128') major_minor_rev = osver[1].to_s + '.' + osver[2].to_s case major_minor_rev when '6.0' : return "Longhorn/Vista" + ' ' + osver[5] when '5.2' : return "Windows Server 2003" + ' ' + osver[5] when '5.1' : return "Windows XP" + ' ' + osver[5] when '5.0' : return "Win2k" + ' ' + osver[5] when '4.90' : return "Windows Me" + ' ' + osver[5] when '4.10' : return "Windows 98" + ' ' + osver[5] when '4.0' : if osver[4] == 2 return "Windows 95" + ' ' + osver[5] else return "Windows NT 4.0" + ' ' + osver[5] end else return "Unknown OS" end end puts system_version Longhorn and Vista appear to share the same version numbers, otherwise that's the general idea. -Charley On 11/15/06, Paul Rogers <[EMAIL PROTECTED]> wrote: > the reason I had it on the ie object is that it comes fromthe user Agent, so > it only applies to the ie object. I do think that some other approach might > be more meaningful though, for example > > Watir::Utils::Environment::OS => "vista" > > Im sure there must be a win api call that gets this stuff, rather than using > the userAgent > > Its in Jira, WTR-116 > > Paul > > ----- Original Message ----- > From: "Charley Baker" <[EMAIL PROTECTED]> > To: <wtr-general@rubyforge.org> > Sent: Wednesday, November 15, 2006 12:51 PM > Subject: Re: [Wtr-general] detecting versions of browser and os > > > > Paul, > > > > I'm not currently testing with IE 7 but most likely will be soon, > > particularly since the upgrade is part of the system updates which > > means the user base will expand quickly. Can you add a JIRA task for > > this? > > > > While the browser version makes sense in context of the ie object, > > the os version and language don't. They'd make more sense to me in the > > context of the Watir module, possibly in their own class, Environment? > > Other thoughts? > > > > -Charley > > > > On 11/11/06, Paul Rogers <[EMAIL PROTECTED]> wrote: > >> > >> > >> I think, now that we have vista, ie7 etc, that the following would be > >> useful: > >> > >> ie.browser_version => "IE7" > >> ie.os => "XP" > >> ie.os_language =>"en-us" > >> > >> etc > >> > >> as Im sure, many people like me now either need to test multiple > >> browsers/os > >> or at least need to know what it was tested on. > >> > >> I have most of the code, I just need to know if there are any comments on > >> method names etc? > >> > >> Paul > >> > >> _______________________________________________ > >> Wtr-general mailing list > >> Wtr-general@rubyforge.org > >> http://rubyforge.org/mailman/listinfo/wtr-general > >> > >> > > _______________________________________________ > > Wtr-general mailing list > > Wtr-general@rubyforge.org > > http://rubyforge.org/mailman/listinfo/wtr-general > > > > > _______________________________________________ > Wtr-general mailing list > Wtr-general@rubyforge.org > http://rubyforge.org/mailman/listinfo/wtr-general > _______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general