Something like the following code can be used to get the browser version and OS version. I'll probably extend this to work with Firefox and other OS
class IE
# returns the browser version
# based on http://blogs.msdn.com/ie/archive/2006/09/20/763891.aspx
# and http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/aboutuseragent.asp
def browser_version
n = self.document.invoke('parentWindow').navigator.appVersion
if m=n.match(/MSIE\s(.*?);/)
return m[1]
end
return ""
end
# this method gets the os version from the browsers useragent string
# based on http://blogs.msdn.com/ie/archive/2006/09/20/763891.aspx
# and http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/aboutuseragent.asp
def os_version
b = self.document.invoke('parentWindow').navigator.appVersion
if n=b.match(/Windows NT(.*?);/)
if n[1].strip == "5.1"
return "Windows XP"
elsif n[1].strip == "5.2"
return "Windows 2003 Server"
elsif n[1].strip == "6.0"
return "Vista"
else
return ""
end
end
return ""
end
end