How do I open tabs using a Watir in ruby How do I open tabs using a Watir in ruby selenium selenium

How do I open tabs using a Watir in ruby


As already mentioned Selenium doesn't explicitly support opening of tabs, however there are 'workarounds' such as...

require 'watir-webdriver'browser = Watir::Browser.new :ffbrowser.goto 'http://the-internet.herokuapp.com'browser.link(:text, 'A/B Testing').click(:command, :shift)browser.windows.last.use

This will open the link in a new tab (on a mac) and focus it


You can use javascript :

require 'watir' # Crawlerbrowser = Watir::Browser.new :chrome   #or firefox in your casebrowser.goto 'http://example.com'browser.execute_script('window.open("http://example1.com")')


Watir does not care if a new page opens in a new window or in a new tab, so use window switching API to switch to the new tab after open it.

http://watir.com/guides/windows/