How To Run Test Cases Using Apple Safari In Selenium Automation Script

This article will tell you how to run the Apple Safari web browser in the selenium webdriver test script. If your Apple Safari version is smaller than version 10.0, you need to install a Safari web browser extension. If your Safari version is equal to or bigger than version 10, the Safari web browser support webDriver by default, then you do not need to install any browser extension.

1. Prerequisites To Run Selenium WebDriver On Safari Browser That Version < 10.

  1. First, you need to download and install the Safari web browser selenium webdriver extension, the extension download URL is
  2. Install the extension by double click your downloaded extension file and click the install button in the popup dialog.
  3. Open Safari web browser and click Safari —> Preferences —> Extensions menu item.
  4. Click the WebDriver item on the Extensions popup window left side.
  5. Then check the Enable WebDriver checkbox on the window right side to enable it.
  6. Restart the Safari web browser if needed.

2. Prerequisites To Run Selenium WebDriver On Safari Browser That Version >= 10.

  1. Safari web browser version 10+ supports selenium webdriver by default, so you do not need to install any extension.
  2. But you should enable the Safari browser Allow Remote Automation option by clicking the Develop —> Allow Remote Automation menu item in Safari.
  3. If you see a checkmark before the Allow Remote Automation menu item, it means the option has been enabled.
  4. If you do not enable this option, when you run the selenium webdriver test script with Safari, you will get the below error message.
    org.openqa.selenium.SessionNotCreatedException: Could not create a session: You must enable the 'Allow Remote Automation' option in Safari's Develop menu to control Safari via WebDriver.

3. How To Launch Safari Web Browser In Selenium Webdriver Example.

  1. Use Safari web browser to run the selenium test script is similar to using IE, Firefox, Chrome.
  2. We need to use a org.openqa.selenium.safari.SafariDriver class instance to do that.
  3. Create an eclipse maven project, and create a java class com.dev2qa.webdriver.safari.SafariBasic in it.
  4. Then add the below java source code to the file.
    package com.dev2qa.webdriver.safari;
    import org.openqa.selenium.By;
    import org.openqa.selenium.Keys;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.safari.SafariDriver;
    public class SafariBasic {
        public static void StartSafari() {
            try {
                //Instantiate apple WebDriver
                WebDriver safariDriver = new SafariDriver();
                // Maximize the Safari browser window.
                //Use apple browser WebDriver to browse web page
                //Sleep 2 seconds to wait for the page load complete
                // Get the google search box object by the search box name.
                WebElement searchBox = safariDriver.findElement("q"));
                // Input search keyword text in the google search box.
                // Press the keyboard Enter key to close the search tips drop-down list and search.
                // Close the Safari web browser.
            }catch(Exception ex){
        public static void main(String[] args) {
  5. Below is the example project source file structure.
    $ tree /F ./
    ├── pom.xml
    ├── src
    │   ├── main
    │   │   ├── java
    │   │   │   └── com
    │   │   │       └── dev2qa
    │   │   │           └── webdriver
    │   │   │               └── safari
    │   │   │                   └──
  6. pom.xml.
    <project xmlns="" xmlns:xsi="" xsi:schemaLocation="">


  1. How To Create Maven Project In Eclipse
  2. How To Add Selenium Server Standalone Jar File Into Your Java Project
  3. How To Use Firefox Webdriver To Launch Firefox Browser Automatically In Java.
  4. How To Run Test Cases Using Google Chrome In Selenium Automation Script.
  5. How To Run Microsoft Internet Explorer And Edge In Selenium Webdriver Automation Script.

3 thoughts on “How To Run Test Cases Using Apple Safari In Selenium Automation Script”

  1. Hi safari,

    Is there any possibility of running selenium script chrome driver in IPad or Iphone, which is connected to windows 10 laptop.
    I want to check the website on both Android and IOS devices but i don’t have mac.

Leave a Comment

Your email address will not be published. Required fields are marked *

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