Tuesday, July 7, 2015

EASY 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)” 

  • Click on “Continue”


You will see the following page :-


  • 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 !!

Happy Coding !!



Credits: itisatechiesworld

No comments:

Post a Comment