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

Advertisements

12 responses to “Steps to get Safari Webdriver running on Mac OSX

    • Hey I’m sorry about this.. But it’s very difficult to get dmg files of previous Safari browser version… This is part of Apple’s strategy of ensuring security to the OS… They don’t want users to be on older versions of the browser as later versions might have some critical security enhancing features..

      Like

  1. Hi ,

    This post was very help full in guiding me to start WebDriver for safari.

    However, I am trying the same for Grid setup. Being novice, could you please provide me some basic on how to start hub and java remote web driver code.

    Any assistance will be grateful.

    Like

    • Hi Bala,
      Glad that you found this post helpful. However I’ve not worked on Selenium Grid uptil now. Java remote web driver is nothing but a webdriver jar which is installed which can be invoked when scripts are being scheduled from remote locations. You should get more info about this as you browse through more articles. It’s been a while since I’ve worked on Selenium, so….

      Like

  2. Hi,

    Is there any way we can execute Selenium tests on Safari in Mac.

    Mac OS : OS X El Capitan 10.11.6
    Safari version : 9.1.3
    Selenium Webdriver used: 2.48 for C#
    I have added selenium webdriver extension (2.48) to Safari browser.

    The safari browser is launched after executing the code “driver= new SafariDriver();” and then this error throws up.
    The error is”Specified cast is not valid” at OpenQA.Selenium.Remote.RemoteWebDriver.

    I have used RemoteWebDriver, IWebDriver and SafariWebDriver but still the same issue is thrown. Can you please help.

    Regards,
    Aditya

    Liked by 1 person

  3. Pingback: Preparing Jenkins to Do QA Testing Automation – rezasetiadi

  4. I am getting the error when I ran on Yosemite 10.10.5 and Safari verion 10 as
    ” Exception in thread “main” org.openqa.selenium.WebDriverException: SafariDriver requires Safari 10 running on OSX El Capitan or greater.
    Build info: version: ‘3.0.1’, revision: ‘1969d75’, time: ‘2016-10-18 09:48:19 -0700’
    System info: host: ‘chetans-MacBook-Pro.local’, ip: ‘192.168.2.8’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.10.5’, java.version: ‘1.8.0_121’
    Driver info: driver.version: SafariDriver
    at org.openqa.selenium.safari.SafariDriver.getExecutor(SafariDriver.java:75)
    at org.openqa.selenium.safari.SafariDriver.(SafariDriver.java:62)
    at org.openqa.selenium.safari.SafariDriver.(SafariDriver.java:42)
    at excel.SafariTest.main(SafariTest.java:9)

    Can anyone help me out.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s