Search code examples
safariprotractorsafaridriver

Failed to connect to SafariDriver (Safari 10)


I'm getting the following error when running my protractor test on mac for safari

Failed to connect to SafariDriver after 10082 ms
Build info: version: '2.53.1', revision: 'a36b8b1',     
os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_101'
Driver info: driver.version: SafariDriver

capability:

        name: 'Safari',
        browserName: 'safari',
        logName: 'Safari',
        shardTestFiles: true,
        maxInstances: 2

Do we need a specific safari driver for this? If yes, where can I get it from and where should it be declared in the .conf file.

Thank you!


Solution

  • Yes, you need to install a specific safari driver in order to launch it inside of protractor. And of course, you need to be on a mac. Protractor is essentially a layer built on top of Selenium, so you need to install the selenium driver for Safari, which is implemented as a Safari plugin.

    Here is what you need to do:

    1. Download the safari plugin from here.
    2. Run the plugin
    3. Select "Trust" the plugin when prompted by safari

    The driver is now installed and should be available to your protractor process.

    This is the driver for Selenium 2.48. I couldn't find a more recent build, so if this driver version doesn't run with the current version of Protractor, you will need to either use an older version of protractor that is based on Selenium 2.48 or build the safari driver from source.