Google+

Safari Browser - Executing Selenium Automation scripts on a Safari Browser

Safari Browser Safari is a web browser developed by Apple and can be used on both Windows and Macintosh machines.



Selenium compatibility with Safari Browser:

Before running Selenium Automation scripts on a Safari Browser, we have to first understand the below things:
  • Though Safari browser can be installed on Windows machine, Apple decided to discontinue Safari browser on Windows machines from the year 2012. So the last and final version of the Safari browser that can be used on the windows machines till date is Safari 5. Hence we cannot use the latest browser from version 6 to 10+ on windows machines.
  • In the mean time Selenium also deprecated SafariDriver which can be used to run the Selenium Automation scripts on Safari browser. Instead of using SafariDriver for running Selenium scripts on Safari browser, Selenium has provided 'Selenium WebDriver' extension for Safari browser. Though Selenium has provided 'Selenium WebDriver' extension for Safari browser to run the Selenium Scripts on Safari browser, this 'Selenium WebDriver' will work only on the Safari Browsers having the browser version of 10 and above. 
  • From the above two points, its very clear that, in order to run the Selenium Automation scripts on the Safari browser, we have to use Safari 10+ browser version for installing 'Selenium WebDriver' Safari browser extension. And as the Safari 10+ browser version is no where supported by Windows machine and can only be installed on the machines having latest versions of Macintosh operating systems. Hence we can only run the Selenium Automation scripts on latest versions of Macintosh machines having Safari browser version of 10+.
  • Safari 10+ browser versions are available only for macOS Sierra. Hence in-order to run the Selenium Automation scripts, we need Safari 10+ browser, which can be installed on one and only Macintosh's macOS Sierra operating system. 
Hence from the above points, we need the below System configuration and plug-ins for running the Selenium Automation scripts on safari browser:
  • Safari 10+ Browser
  • Macintosh macOS Sierra Operating System
  • 'Selenium WebDriver' Safari browser extension

Practical execution of Selenium Scripts on Safari browser:

Using the above configuration, lets practically execute the Selenium Automation scripts on Safari Browser:

1. Open Safari Browser in Macintosh machine and select 'About Safari' option as shown below:



2. Check that the version of Safari Browser is 10+ as shown below:



3.  Close the Safari Browser and select 'About This Mac' option as shown below:



4. Check that the Safari 10+ compatible Macintosh version 'macOS Sierra' is displayed as shown below:



5. Launch Eclipse IDE in Macintosh machine and create a new Java project as shown below:



6. Download the Selenium 2.53.1 jar files from the link http://selenium-release.storage.googleapis.com/index.html?path=2.53/ as  shown below:



7. Extract the downloaded Zip file as shown below:



8.Open the extracted folder as shown below:



9. Copy the below jar files in the extracted folder as shown below:

Add caption


10. Create libraries folder in the Java Project and paste the above copied jar files into the folder as shown below:



11. Open 'libraries' folder from the extracted zip file and copy the jar files as shown below:



12. Paste the copied jar files into the 'libraries' folder of the Project as shown below:



13. Go to Project properties and configure the jar files under 'libraries' folder as shown below:



14. Observe that the jar files got configured as shown below:



15. Create a new Java class in the project as shown below:



16. Create a driver object for SafariDriver class as shown below:



17. Hover the mouse over the above errors and select the option as shown below:



18. Observe that the errors got resolved and write the remaining sample code on Selenium as shown below:



19. Execute the Selenium code and observe that 'Unreachable Browser Exception' got displayed in the Eclipse IDE console as shown below:



20. In order to resolve the above Exception, we have to install 'Selenium WebDriver' extension for Safari browser. Go to Seleniumhq.org > downloads page and click on the latest release link as shown below:



21. Observe that the 'Selenium WebDriver' extension for Safari browser will be downloaded and select to open it as shown below:



22. Click on 'Trust' button on the displayed pop-up window as shown below:



23. Observe that 'Selenium WebDriver' Extension is displayed as installed as shown below:



24. Switch back to Eclipse IDE and execute the same Selenium code now i.e. after installing 'Selenium WebDriver' extension for Safari browser. Observe that the Safari browser will be launched and all the operations related to written Selenium code will be performed on the Safari browser. On successful execution, the below output will be displayed in the Eclipse IDE console as shown below:


Note: Observe that no exception got displayed in the above output, safari browser operations are performed on the UI and hence we can confirm that our script went well.

Conclusion:

In order to execute the Selenium automation scripts on safari browser, we need to use Safari 10+ browser on the supported Macintosh Operating systems like macOS Sierra. Along with this, we need to install 'Selenium WebDriver' extension for Safari browser. But it is now, not possible to run the automation scripts on Windows machines, as Apple has discontinued Safari browser development for windows machines and Safari 5 is the last version available for windows. Hence only way to run the Selenium automation scripts on Safari browser is on Macintosh machine having Safari 10+ browser version along with its 'Selenium WebDriver' extension.

No comments:

Blog Index