I'm in the process of switching my Watir / FireWatir scripts over to use watir-webdriver and need a means in watir-webdriver to determine which type of browser the test is currently being executed against, (IE, FF, Chrome).
With Watir / FireWatir looking at the class of the browser would return either "Watir::IE" or "FireWatir:Firefox". Using that the code could be branched to execute browser specific code.
In watir-webdriver, the class of the browser is always "Watir::Browser", it doesn't vary when running IE, Firefox, or Chrome.
def is_ie?()
return self.class.to_s == "Watir::IE"
end
def is_firefox?()
return self.class.to_s == "FireWatir::Firefox"
end
if(browser.is_ie?)
# run the IE specific code
end
if(browser.is_firefox?)
# run the firefox specific code
end
Thanks in advance,
Joe
Try
browser.driver.browser #=> :firefox
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With