Watir-Webdriver and Safari (10) is easy
tl;dr Extension bad. Safari 10 + selenium-webdriver gem version 3 good. Nothing else required. (Still in buggy beta.)
The standard wisdom on driving Safari with Watir-Webdriver (Google, SO) is to install a SafariDriver browser extension. Unfortunate, because that is wrong.
Do not install the extension if you upgraded to Mac OS X El Capitan or macOS Sierra, or you will.
The browser extension probably won’t eat all of your data, steal your passwords, kill your first-born, etc. But you definitely don’t need it. And you can’t actually use it, because it doesn’t work with the most recent Safari. And did I mention you don’t need it?
You can actually use SafariDriver, right now, and its crazy easy. Apple has baked it into Safari 10.
- Install Safari 10, updating your OS if you must.
- Install the most recent selenium-webdriver. Right now, you need version 3.0 or greater, which is still in beta.
$ gem install selenium-webdriver -- pre #=> 3.0.0.beta4.0 right now
And then you can use it.
> require 'selenium-webdriver'
> require 'watir-webdriver'
> w = Watir::Browser.new :safari
=> #<Watir::Browser:0x..fccba48b56a842c4e url="" title="">
That’s it. Great, right? This Just Works*
Not that you’d know it leafing through the perplexingly monolithic Selenium GitHub. (All the languages are friends!) The overview Wiki SafariDriver examples point to the outdated extension (which you then must search the download folders for). The guide, to be fair: a self-described work-in-progress, is literally blank on the subject.
This is presumably because Safari 10 is new (as of October 2016). So new, in fact, *it doesn’t work properly (again, as of this writing). But, Apple and the selenium-webdriver folks are working on the new paradigm. And the new paradigm is that this stuff will be insanely simple.