How to launch Selenium Script in Safari Browser Using SafariDriver?

Previously SafariDriver was supporting Safari browser on Windows machine but recently Apple has decided to remove its support for windows and then executions on safari has become the job of Mac machine. So for the same, we need a mac machine where safari browser should be installed. But if you want to learn how to launch chrome in Selenium then read this post
Installing Chromedriver on MAC
and for windows. Read this post
Launch Chrome Browser Using WebDriver

So let’s get back to the topic, Safari driver has been implemented as a plugin in the safari browser and this provides a perfect match of client and server machine where SafariDriverServer acts as a server and Selenium-Java/Language binding acts as a client.

SafariDriver

So for the same, we need to download the plugin and it needs to be installed on Safari browser and once plugin installed on Safari everything is set and you can write a script for a safari like any other browser by calling the

WebDriver driver = new SafariDriver();

[the_ad_placement id=”incontent”]So before moving ahead let see the steps to perform these actions.

1- Go to http://selenium.dev

2- Go to Download  and Navigate to Browser Section

3- Again navigate to “Safari” heading and click on documentation link to find the detail of safaridriver.

4- Now click on the hyperlink beside “Latest Release”

5- It will download the plugin and double click on downloaded file and it will open the extension installation screen. Click on “Trust ” button and it will install it in the browser and by default, it will check WebDriver checkbox.

6- Go to your eclipse and write scripts and it will work like any other browser on Mac machine

For better understanding watch video once and if still, you have some doubt then please share your feedback.

Dwarika Dhish Mishra

My name is Dwarika Dhish Mishra, its just my name and I am trying to bring the worth of my name in to actions and wants to be the solution not the problem. I believe in spreading knowledge and happiness. More over I am fun loving person and like travelling a lot. By nature I am a tester and a solution maker. I believe in the tag line of http://ted.org “Idea worth spreading” . For the same, I have created this blog to bring more and more learning to tester fraternity through day to day learning in professional and personal life. All contents are the part of my learning and so are available for all..So please spread the contents as much as you can at your end so that it could reach to every needful people in testing fraternity. I am pretty happy that more and more people are showing interest to become the part your Abode QA blog and I think this is good sign for us all because more and more content would be before you to read and to cherish. You may write or call me at my Email id: dwarika1987@gmail.com Cell: 9999978609

You may also like...

1 Response

  1. vikas garg says:

    Hi ,
    I have done same steps as mentioned by you. But safari browser is not launching, its shown null pointer exception. I have installed safari extension in safari. I have checked that webdriver extension is also enabled. I have selenium server 3.1.0 in my classpath. Following the code:

    {
    System.setProperty(“webdriver.safari.driver”, “./lib/SafariDriver.safariextz”);
    driver = new SafariDriver();
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    return driver;
    }

    java.lang.NullPointerException
    at pouringPounds.browserFunction.DriverFunctions.openURL(DriverFunctions.java:79)
    at pouringPounds.testCases.testClass.test1(testClass.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
    at org.testng.TestRunner.privateRun(TestRunner.java:756)
    at org.testng.TestRunner.run(TestRunner.java:610)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:387)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
    at org.testng.SuiteRunner.run(SuiteRunner.java:289)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1293)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1218)
    at org.testng.TestNG.runSuites(TestNG.java:1133)
    at org.testng.TestNG.run(TestNG.java:1104)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.