Andy Pohl
Andy Pohl

Reputation: 253

Cannot launch Safari browser with Nightwatch

I am using Nightwatch.js to build/run end to end tests on our web app, and as part of our build process, we want to integrate it with Jenkins. On my local machine, I am able to run my tests, on all three browsers (Firefox, Safari, Chrome) at the same time with no issue. I can also run on an individual browser with no issue. I have the correct and most recent versions of the selenium driver, and am pointing to them in my nightwatch.json file. For some reason, however, I am not able to launch Safari on the dedicated machine that is running these tests when a new Jenkins build comes in. Everything is set up the exact same way on that machine as it is on my on, but I keep getting the error

     Error retrieving a new session from the selenium server
     Failed to connect to SafariDriver after 10066ms

When this happens, both Chrome and Firefox are able to load with no problem, only Safari has the issue. We made sure to download the most recent version of the standalone selenium driver for Safari, and I did it again just to be sure. I've also made sure to check if there happens to be another instance of the selenium server running, but it's never the case

My nightwatch.json file looks like this....

     {
      "src_folders" : ["test"],
      "output_folder" : "reports",
      "custom_commands_path" : "node_modules/nightwatch-custom-commands-         assertions/js/commands",
      "custom_assertions_path" : "node_modules/nightwatch-custom-commands-assertions/js/assertions",
      "page_objects_path" : "",
      "globals_path" : "",

      "selenium" : {
        "start_process" : true,
        "server_path" : "lib/selenium-server-standalone-2.53.0.jar",
        "log_path" : "",
        "host" : "127.0.0.1",
        "port" : 4444,
        "cli_args" : {
         "webdriver.chrome.driver" : "lib/chromedriver",
         "webdriver.safari.driver" : "lib/selenium-server-standalone-2.53.0.jar"
         }
      },

      "test_settings" : {
        "firefox" : {
           "launch_url" : "http://localhost",
           "selenium_port"  : 4444,
           "selenium_host"  : "localhost",
           "silent": true,
           "screenshots" : {
             "enabled" : false,
             "path" : "./screenshots"
           },
          "desiredCapabilities": {
            "browserName": "firefox",
            "javascriptEnabled": true,
            "acceptSslCerts": true
           },
          "end_session_on_fail": false,
          "skip_testcase_on_fail": false
        },

        "chrome" : {
          "launch_url" : "http://localhost",
          "selenium_port"  : 4444,
          "selenium_host"  : "localhost",
          "silent": true,
          "screenshots" : {
            "enabled" : false,
            "path" : "./screenshots"
          },
          "desiredCapabilities": {
            "browserName": "chrome",
            "javascriptEnabled": true,
            "acceptSslCerts": true
          },
          "end_session_on_fail": false,
          "skip_testcase_on_fail": false
        },

        "safari" : {
          "launch_url" : "http://localhost",
          "selenium_port"  : 4444,
          "selenium_host"  : "localhost",
          "silent": true,
          "screenshots" : {
            "enabled" : false,
            "path" : "./screenshots"
          },
          "desiredCapabilities" : {
            "browserName" : "safari",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
          },
          "end_session_on_fail": false,
          "skip_testcase_on_fail": false
       }
    }
 }

If anyone has any insight to why this might be happening I'd appreciate it. Thanks

Upvotes: 2

Views: 1626

Answers (2)

Shri
Shri

Reputation: 81

You would have to manually install SafariDriver. SafariDriver can be found here.

To check if safariDriver is enabled or not go to Safari>Preferences>Extensions>Here enable webDriver extension. It should be enabled by default but just in case if you need to debug. Thanks

Upvotes: 3

Andy Pohl
Andy Pohl

Reputation: 253

UPDATE*****

Turns out there is an extension for Safari that needs to be installed for selenium driver to work.

Upvotes: 0

Related Questions