Steps to get Safari Webdriver running on Mac OSX

Since this topic has not been well documented on the net and I struggled myself to get Selenium tests running on Safari browser, here are the complete set of steps to get Selenium tests up and running on Safari browsers. :-

Creating “Safari Extension” Developer Certificate

  1. Create an Apple developer account.
  • Go to https://developer.apple.com/
  • Click on “Member Center” on top panel.
  • Select “Create Apple ID”.
  • Go through the sign up forms and provide valid fields for a succesful sign up

2.  Login to created Apple account.

3.  Sign up for “Safari Extensions” developer

  • Click on “Certificates, Identifiers & Profiles”
  • In the “Safari Extensions’ section, click on “Join Now”
  • Go through the following steps and provide valid fields to successfully sign up for the “Safari Extensions” program

4.  Create “Developer Certificate”

  • Now inside “Certificates, Identifiers & Profiles” > “Click on Create/Add Safari Certificate”
  • You will see the following page – “About Creating a Certificate Signing Request (CSR)” Screen Shot 2015-04-15 at 1.40.24 pm
  • Click on “Continue”

You will see the following page :-Screen Shot 2015-04-15 at 1.40.42 pm

  • Upload the CSR file and Click on ‘Generate’ to generate the certificate
  • Now download the certificate once it is generated.

5. Download the certificate and install in the machine

  • Download the certificate in the download tab.
  • The certificate is downloaded as “safari_extension.cer”.
  • Double-click on the file to install the certificate in the Mac client/OSX.

6.  We have installed the safari extensions certificate for developers. Now we need to install the Safari Webdriver extension for the Safari Browser.

 Installing the Safari Webdriver extension in the Safari Browser

  1. Download latest Selenium Safari extension.

2.  Install the Safari Extension

  • Double-click on the “SafariDriver.safariextz” file.
  • You will get a prompt asking “Are you sure you want to install the extension “WebDriver”?“.
  • Click on “Install”

3.  Provide the default setting for the Selenium Webdriver Extension.

  • Click on “Safari” > “Preferences” > “Extensions” > You will find Selenium extension
  • Select “Enable Webdriver”

Now all the settings are done and now we should be able to launch our Selenium scripts using Safari Webdriver.

Launching Safari Webdriver

Webdriver driver = new SafariDriver();                

driver.get( http://www.google.co.in” );

builder = new Actions(driver);

This should launch your safari browser with the Safari Webdriver Extension 🙂

Hope this article comes of use to you all.

UPDATE (18th June,2015): With the latest update of Yosemite 10.10.3 & Safari 8.0.6, the execution on Safari Browsers has become unstable & unreliable.

Selenium Scripts work best on 10.10.2 , Safari 8.0.3 & Selenium 2.45.0 combination.

So if OSX prompts you for updates, please DO NOT install them if you want to run automation on Safari Browser

Regards,

VJ