Failed to connect to SafariDriver (Safari 10)

后端 未结 2 803
小蘑菇
小蘑菇 2021-01-02 23:48

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.         


        
相关标签:
2条回答
  • 2021-01-03 00:38

    First of all, starting with Safari 10, Safari comes bundled with a new driver implementation. The old driver (the extension) is deprecated. You're using macOS 10.12.2, so it's your case. To enable the new driver in Safari, toggle the Allow Remote Automation checkbox in the Develop menu. If you don't have this menu, enable it: Preferences > Advanced > Show Develop menu in menu bar. Start /usr/bin/safaridriver once manually to grant it the permissions needed.

    Secondly, you need a 3.x version of the Selenium Standalone Server, not 2.53.1. The command to install it:

    sudo webdriver-manager update --versions.standalone 3.0.1
    

    To start:

    webdriver-manager start --versions.standalone 3.0.1
    

    Thirdly, the visibility checks are broken in the new driver. So things like browser.wait(ExpectedConditions.visibilityOf(myElement), 5000); don't work and lead to UnsupportedCommandException. In order to fix this, you can try installing Safari Technology Preview and running tests there (add 'safari.options': { technologyPreview: true } to the capabilities). But for me, the preview works even worse than the release. Protractor says it can't find Angular on the page because they changed window.name to be cleared after a cross-origin navigation in the Release 19. If you happen to find a way to make it work, please let me know.

    Below are some links you should check because I might have missed something.

    • The blog post that announces the new driver in Safari 10
    • Issues in the Protractor project:
      • Safari 10 failing with the latest protractor
      • Safari Technology Preview can't find Angular 1
    0 讨论(0)
  • 2021-01-03 00:42

    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.

    0 讨论(0)
提交回复
热议问题