Starting a Session  

Opening a Browser

Once you’ve installed Watir, and your desired drivers, and have an open irb session, you can try out opening a browser with:

require 'watir'
browser =

to close the browser:


By default Watir will open a Chrome Browser. To open other browsers, specify the one you want as the first argument: :firefox :internet_explorer :edge :safari

To open a browser on a remote machine, specify the url after the browser argument :firefox, url: "http://#{the_grid_url}:4444/wd/hub"

Check out the Capabilities Guide for how you can both ensure that you are getting the session you want, and to specify how the browser should behave during the session.

Last Updated: March 12, 2021