javascriptsafarinightwatch.jssafaridriver

How to use Safari Technology Preview in nightwatch?


I didn't find any information on how to properly setup the nightwatch config using Safari technology preview.

I've tried something like this:

module.exports = {
    "src_folders": [
        "suites"
    ],
    "output_folder": "reports",
    "custom_commands_path": "commands",
    "page_objects_path": "pageObjects",
    "globals_path": "globals.js",
    "selenium": {
        "start_process": true,
        "server_path": seleniumServer.path,
        "host": "127.0.0.1",
        "port": 4444,
        "log_path": "logs",
        "cli_args": {
            "webdriver.chrome.driver": chromedriver.path,
            "webdriver.firefox.driver": '/usr/bin/geckodriver',
            "webdriver.safari.driver": '/usr/bin/safaridriver'
        }
    },
    "test_settings": {
        "default": {
            "launch_url": "http://google.com",
            "screenshots": {
                "enabled": true,
                "on_failure" : true,
                "on_error" : true
            },
            "globals": {
                "waitForConditionTimeout": 5000,
                "retryAssertionTimeout": 5000
            },
            "desiredCapabilities": {
                "browserName": "safari",
                "browserVersion": "12",
                "technologyPreview": true
            },
            "skip_testcases_on_fail": false,
            "end_session_on_fail": false
        }
    }
};

But after execution I get this error:

{ value: 
   { message: 'Could not create a session: A browser with name \'safari\' version \'12\' could not be found on the system.\nBuild info: version: \'3.13.0\', revision: \'2f0d292\', time: \'2018-06-25T15:32:19.891Z\'\nSystem info: host: \'Boostas-MacBook-Pro-5.local\', ip: \'fe80:0:0:0:100a:70f9:d6d7:cbfc%en0\', os.name: \'Mac OS X\', os.arch: \'x86_64\', os.version: \'10.13.6\', java.version: \'10.0.1\'\nDriver info: driver.version: unknown\nremote stacktrace: ',
     error: 'session not created' },
  status: 33 }

Note: If I set technologyPreview to false the test will be run in Safari browser.

Hope you guys can help me!


Solution

  • Those two options worked in my case in nightwatch.json to launch Safari Technology Preview :

      "desiredCapabilities": {
        "browserName": "safari",
        "safari.options": {"technologyPreview": true},
      }
    

    Useful reference : https://macops.ca/using-safari-technology-preview-with-selenium-webdriver/

    Hope this helps !