Code for Selenium WebDriver IE Browser :
require 'rubygems'
require 'selenium-webdriver'
br=Selenium::WebDriver.for :ie
ie=br.execute_script("return navigator.userAgent;")
# Ex. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C)"
puts ie.split("MSIE ")[1].split(";")[0]
OUTPUT –> 9.0
——————————————————————————————————————————————-
Code for Selenium WebDriver Firefox Browser :
require 'selenium-webdriver'
br=Selenium::WebDriver.for :ff
ff=br.execute_script("return navigator.userAgent;")
# Ex. "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0"
puts ff.split("/")[-1]
OUTPUT –> 12.0
——————————————————————————————————————————————-
Code for Watir WebDriver IE Browser :
require 'rubygems'
require 'watir-webdriver'
br=Watir::Browser.new :ie
ie=br.execute_script("return navigator.userAgent;")
puts ie.split("MSIE ")[1].split(";")[0]
OUTPUT –> 9.0
——————————————————————————————————————————————-
Code for Watir WebDriver Firefox Browser :
require 'rubygems'
require 'watir-webdriver'
br=Watir::Browser.new :ff
ff=br.execute_script("return navigator.userAgent;")
puts ff.split("/")[-1]
OUTPUT –> 12.0
——————————————————————————————————————————————-