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
- 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.
- Now, you’ll need to build the extension. First, you’ll need to check out the selenium source code to do so:
svn co http://selenium.googlecode.com/svn/trunk selenium
- Then change into this directory and build the extension
cd selenium ./go safari
- 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-webdriver' b = Watir::Browser.new :safari
- 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