Watir-WebDriver supports Safari thanks to the release of SafariDriver.

The downside is the set up is quite lengthy at the moment as it requires a Safari extension (version 5+) and until someone publishes the extension to the online gallery, you’ll have to build it yourself.

Steps to build the extension

  1. First, create and install a Safari extension certificate at Apple. You’ll need to sign up for a (free) Safari developer account, and download your certificate locally.

  2. Now, you’ll need to build the extension. First, you’ll need to check out the selenium source code to do so:

svn co selenium
  1. Then change into this directory and build the extension
cd selenium
./go safari
  1. Finally, install your extension:
    • Launch Safari
    • Ensure develop menu is shown by setting it in Advanced Preferences
    • Open the Extension Builder (Develop > Show Extension Builder)
    • Add your new extension from:

Using Safari with Watir-WebDriver

It’s exactly the same as any other browser:

require 'watir'
b = :safari

Caveat Emptor

  • browser.execute_script is a little flaky
  • Can’t use local html files as extensions don’t load
  • Can’t perform browser file uploads at present
  • Not sure how to configure browser options programatically like user agent strings