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:
- Then change into this directory and build the extension
- 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:
- 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