some one on irc wanted to get the browser and os versions. THis code uses the user-agent, so might not always be correct, but its probably good enough. Not sure if it works on IE8
It came from a module that was included into the Watir and FireWatir modules. Its from an old code base, so may need some help making it work on newer versions of watir Paul # 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 if self.class.ancestors.collect{|c| c.to_s}.include? "Watir::IE" version = self.document.parentWindow.navigator.appVersion if v = /compatible; MSIE (.*?);/.match(version) version = v[1] end app = self.document.parentWindow.navigator.appName else cmd = "#{FireWatir::Firefox::WINDOW_VAR}.navigator.userAgent" @jssh_socket.send("#{cmd}\n", 0) useragent = read_socket() if m=/(Firefox)\/(.*)/.match( useragent) app =m[1] version = m[2] end end return app , version 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 if self.class.ancestors.collect{|c| c.to_s}.include? "Watir::IE" b = self.document.invoke('parentWindow').navigator.appVersion else cmd = "#{FireWatir::Firefox::WINDOW_VAR}.navigator.userAgent" @jssh_socket.send("#{cmd}\n", 0) b = read_socket() end 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 else if b.match(/Macintosh/) return "Mac" end end return "??" end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---