Safari 10 Automated Testing with Apple’s SafariDriver

safaridriver testing
Starting with macOS Sierra, Apple’s now providing a SafariDriver that comes pre-installed with the OS.

This is great news:

  • A driver provided and updated by the browser vendor itself is a good thing! There are no hacks required to automate the browser, since the vendor itself can modify the browser and driver to work perfectly together.
  • In this case, the previous SafariDriver (now deprecated) was implemented as a Safari browser extension. It works pretty good, but might be slow at times.

At TestingBot, we’ve been providing Safari 10 testing ever since macOS was released. For Safari 10 testing, we’re still using the deprecated SafariDriver as a browser extension.

Now, we’re also providing Safari testing with the Apple SafariDriver! All you need to do for now is to specify you want to use Selenium 3 during your test:

desired_capabilities = {
  browserName: "safari",
  version: 10,
  "selenium-version": "3.0.1"
}

TestingBot will then automatically make sure your test uses Apple’s SafariDriver.
Once the default Selenium version is bumped to Selenium 3 on TestingBot, all Safari 10 tests will automatically use the new SafariDriver.

When you run a test with the new SafariDriver, you might notice some changes in behavior:

  • The address bar will have an orange Smart Search field (address bar).
  • Similar to Private Browsing, tests will run from a clean slate and cannot access Safari’s normal browsing history, autofill data or other sensitive data.
  • During a test, you can pause a test from our TestingBot member dashboard. You can then live interact with the browser. By default, Safari will add a “glass pane” in front of the window which prevents you from influencing the test. Simply clicking this will allow you to use Web Inspector for manual debugging.
  • At the start of your test, you can specify ‘automaticInspection’ and ‘automaticProfiling’ in your desired capabilities. This will make sure Web Inspector and the Profiler start collecting data as soon as your test starts. When you pause a test, you can immediately access this data from the Web Inspector.

You can find more information about Apple’s new SafariDriver on the WebKit blog.

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *