Unable to run tests on Safari - Do we need dev cer

2019-04-11 11:46发布

问题:

I am trying to run my protractor tests on Safari. While researching, I learnt that you need not download anything in specific for Safari when using protractor because the driver comes with it. When attempting to run my tests I was getting "No Safari driver" found message. Then I installed this extension for Safari - from the link below.

https://code.google.com/p/selenium/wiki/SafariDriver

http://selenium-release.storage.googleapis.com/index.html?path=2.45/

This extension does show up on preference - Extension on Safari. While running my tests, I initially get this and then it navigates to Blank window. Nothing happens after that... Do we have to buy the Apple dev subscription in order for us to use safari? I was hoping to run my appium tests on iOS devices and I doubt that Safari will work even with mobile browsers.

What are my options? Is paying the only way to get Safari work on a Mac?

I have MacBook Pro - Yosemite - 10.10.4 Safari - 8.0.7

[ 0.002s] [safaridriver.client] Connecting to SafariDriver browser extension... [ 0.002s] [safaridriver.client] This will fail if you have not installed the latest SafariDriver extension from http://selenium-release.storage.googleapis.com/index.html [ 0.003s] [safaridriver.client] Extension logs may be viewed by clicking the Selenium [✓] button on the Safari toolbar [ 0.005s] [safaridriver.client] Connected to extension [ 0.006s] [safaridriver.client] Requesting extension connect to client at ws://localhost:13871

回答1:

I had Selenium 2.45 installed, and this is what I did to get SafariDriver working on OS X 10.9.5 with Selenium 2.46:

  1. Uninstall current SafariDriver from Safari (Preferences > Extensions > WebDriver 2.45.0 > Uninstall)
  2. Download and unzip Selenium 2.46 for Java (http://selenium-release.storage.googleapis.com/2.46/selenium-java-2.46.0.zip)
  3. Unzip /selenium-2.46.0/selenium-java-2.46.0.jar
  4. Find and double-click /selenium-2.46.0/selenium-java-2.46.0/org/openqa/selenium/safari/SafariDriver.safariextz

This will install, what I believe is, SafariDriver 2.46.0. It will be listed in Safari as WebDriver 2.45.0, but the file date is newer, and it worked for me.