Starting a browser with a specific profile 10/10/2012
# Starting the browser with a new default profile
profile = Selenium::WebDriver::Firefox::Profile.new
browser = Watir::Browser.new :firefox, :profile => profile

# Starting the browser with a modified profile
profile = Selenium::WebDriver::Firefox::Profile.new
profile.native_events = false
browser = Watir::Browser.new :firefox, :profile => profile

It is sometimes useful to start the browser with a specific profile. It could be due to wanting to have an addon available while running tests (Firebug) or something else, like disabling native events as shown in the example above.

Catching exceptions 24/08/2012
begin
  browser.link(:id => 'not existing').click
rescue Watir::Exception::UnknownObjectException
  # Do something useful
  p "Element not found"
end

Sometimes there are exceptions coming back from the webdriver due to several possible problematic situations. For example, an element is not found or it is not clickable. The tests should not break in such a situation but the exceptions should be handled gracefully.

Starting Chrome 26/07/2012
browser = Watir::Browser.new :chrome

This is the command to start Chrome with watir-webdriver. All Chrome versions are started with the same command. The version that starts depends on which version is installed on the PC.

Starting Internet Explorer 26/07/2012
browser = Watir::Browser.new :internet_explorer

This is the command to start Internet Explorer with Webdriver. All IE versions are started with the same command. The version that starts depends on which version is installed on the PC.

Starting Firefox 26/07/2012
browser = Watir::Browser.new :firefox

This is the command to start a new browser. The browser can be specified with a symbol. Webdriver supports major browsers.