Reputation: 493
I have been running e2e tests in an AngularJS web-app using protractor, testing on Chrome and Firefox. When adding safari to my array, the following is displayed:
"Unable to establish a connection with the SafariDriver extension"
I have found a way to solve this locally but as we are using Codeship to automate our builds, I need a way to solve it rather than having to manually add the driver to selenium and enable in Safari.
I am using selenium 2.43.1
config:
exports.config = {
baseUrl: 'http://localhost:9001',
multiCapabilities: [{
'browserName': 'chrome'
}, {
'browserName': 'firefox'
}, {
'browserName': 'safari'
}],
specs: ['e2e/app.js']
};
package.json:
{
"name": "livingthevalues",
"version": "0.0.0",
"dependencies": {
"express": "^4.9.7",
"gzippo": "^0.2.0",
"bower": "^1.3.8",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-autoprefixer": "^0.7.3",
"grunt-concurrent": "^0.5.0",
"grunt-contrib-clean": "^0.5.0",
"grunt-contrib-compass": "^0.7.2",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-copy": "^0.5.0",
"grunt-contrib-cssmin": "^0.9.0",
"grunt-contrib-htmlmin": "^0.3.0",
"grunt-contrib-imagemin": "^0.8.1",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-uglify": "^0.4.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-filerev": "^0.2.1",
"grunt-google-cdn": "^0.4.0",
"grunt-newer": "^0.7.0",
"grunt-ng-annotate": "^0.3.0",
"grunt-svgmin": "^0.4.0",
"grunt-usemin": "^2.1.1",
"grunt-wiredep": "^1.7.0",
"jshint-stylish": "^0.2.0",
"load-grunt-tasks": "^0.4.0",
"time-grunt": "^0.3.1"
},
"devDependencies": {
"chai": "^1.9.2",
"chai-as-promised": "^4.1.1",
"cucumber": "^0.4.4",
"grunt-karma": "^0.9.0",
"grunt-protractor-runner": "^1.1.4",
"karma": "^0.12.17",
"karma-chrome-launcher": "^0.1.4",
"karma-jasmine": "^0.1.5",
"karma-junit-reporter": "^0.2.2",
"karma-mocha": "^0.1.6",
"karma-phantomjs-launcher": "^0.1.4",
"protractor": "^1.3.1",
"protractor-cucumber": "^0.1.2",
"sinon": "^1.11.0"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "grunt test",
"pree2e": "./node_modules/protractor/bin/webdriver-manager update",
"e2e": "grunt test:e2e"
}
}
commands run by ci:
Exporting Environment
0 min 2 sec
git clone --branch 'commentBox' --depth 50 [email protected]:MyTeam/myrepo.git ~/src/github.com/MyTeam/myrepo
0 min 1 sec
cd clone
0 min 1 sec
git checkout -qf 2ec65e3b32971d0f7f9de948c40f019f0629adea
0 min 1 sec
Preparing Dependency Cache
0 min 10 sec
Preparing Virtual Machine
0 min 5 sec
rvm use 2.0.0-p195
0 min 5 sec
bundle install
0 min 2 sec
nvm install 0.10.25
0 min 2 sec
nvm use 0.10.25
0 min 1 sec
npm install
0 min 7 sec
bower instal
0 min 7 sec
npm test
0 min 10 sec
npm run e2e
Thanks - seems like such a simple thing to do but can't understand why it isn't working.
Upvotes: 1
Views: 4947
Reputation: 7286
On Mac, The Selenium SafariDriver extension you used to have to install is now depreciated. On El Capitan & Sierra Apple provides it's own Safaridriver. Uninstall previous safaridriver extension (if you had installed it) and enable the new safaridriver, excerpt from link 2:
/usr/bin/safaridriver -p 8000
Also, You need to be running Selenium 3.0 + (support started at 3.0.0-beta1) to use the new safari driver.
Note: If you still have trouble maybe check the Addendum at bottom of the 2nd link. Another caveats I ran into, the new safaridriver only supports one session so maxSessions=# is no longer supported. Also, if you use npm selenium-standalone install you can update selenium version like so.
selenium-standalone install --version=3.0.1 --baseURL=https://selenium-release.storage.googleapis.com
And then boot hubs and nodes with the --version=3.0.1 flag.
Upvotes: 2
Reputation: 37816
I'm using Windows 7.
Prerequisite: Install Safari on Windows
It's now time to instantiate SafariDriver and get the desired URL as below:
WebDriver driver = new SafariDriver();
driver.get("https://www.packtpub.com/web-development/mastering-selenium-testing-tools-video");
Upvotes: 0
Reputation: 191
I'm wrestling with this exact issue trying to automate our tests against Safari 7.1. My research so far leads me to believe that with Safari 7.1, a new security model was put into place to make extensions more secure. Here is a related thread fwiw. I have tried using the mvn command line to install the SafariDriver extension but it fails to do so. I've tried running a simple command line to open Safari with the extension as a parameter but then you are prompted to enable/install it. (no good for unattended flows). Another hack that was suggested was to go directly to the plist file that Safari uses for preferences/extensions but I could not find it on Mac 10.10. I'm quite anxious to know the answer here.
Upvotes: 2