Skip to content

Commit

Permalink
make tests working in safari, run env tests via simple NPM commands
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Aug 11, 2014
1 parent 15f9b18 commit 3b93c76
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ env:
- _BROWSER: "internet_explorer"
_PLATFORM: "Windows_8"
_VERSION: "10"
- _BROWSER: "safari"
_PLATFORM: "Windows_7"
_VERSION: "5"
- _BROWSER: "Safari"
_PLATFORM: "iOS"
_APP: "safari"
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
},
"scripts": {
"test": "node ./test/runner.js",
"test-mobile": "_APP=safari _BROWSER=safari _PLATFORMVERSION=7.1 _APPIUMVERSION=1.2 _PLATFORMNAME=iOS _DEVICENAME=iPhone_Simulator _PORT=4723 _ENV=mobile node ./test/runner.js",
"test-desktop": "_ENV=desktop _BROWSER=chrome node ./test/runner.js",
"test-functional": "_ENV=functional _BROWSER=phantomjs node ./test/runner.js",
"coverage": "./node_modules/.bin/istanbul cover -x \"**/helpers/is*.js\" -x \"**/helpers/click.js\" -x \"**/helpers/has*.js\" -x \"**/helpers/getHTML.js\" -x \"**/helpers/scroll.js\" -x \"**/helpers/newWindow.js\" ./test/runner.js",
"prepublish": "npm prune"
},
Expand Down
4 changes: 2 additions & 2 deletions test/conf/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module.exports = {
subPage: 'http://127.0.0.1:8080/test/site/www/two.html'
},
host: 'localhost',
port: 4444,
port: process.env._PORT || 4444,
logLevel: 'silent',
desiredCapabilities: {
browserName: 'phantomjs'
browserName: process.env._BROWSER || 'phantomjs'
}
};
2 changes: 1 addition & 1 deletion test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(env === 'functional') {
specFiles = '{test/spec/' + env + '/*.js,test/spec/*.js}';
}

glob(specFiles, function(er, files) {
glob(process.env._SPEC || specFiles, function(er, files) {

files.forEach(function(file) {
mocha.addFile(file);
Expand Down
10 changes: 10 additions & 0 deletions test/spec/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ describe('cookie command test', function() {
});

it('deleteCookie should delete a specific cookie', function(done) {

if(this.client.desiredCapabilities.browserName === 'safari' && !this.client.isMobile) {
return done();
}

this.client
.setCookie({ name: 'test', value: 'cookie saved!' })
.setCookie({ name: 'test2', value: 'cookie2 saved!' })
Expand All @@ -63,6 +68,11 @@ describe('cookie command test', function() {
});

it('deleteCookie should delete all cookies', function(done) {

if(this.client.desiredCapabilities.browserName === 'safari' && !this.client.isMobile) {
return done();
}

this.client
.setCookie({ name: 'test', value: 'cookie saved!' })
.setCookie({ name: 'test2', value: 'cookie2 saved!' })
Expand Down
4 changes: 2 additions & 2 deletions test/spec/getLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ describe('getLocation', function() {
/**
* between devices and platform this can be different
*/
location.x.should.be.below(25);
location.y.should.be.below(25);
location.x.should.be.below(27);
location.y.should.be.below(27);
})
.call(done);
});
Expand Down
30 changes: 30 additions & 0 deletions test/spec/isEnabled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*jshint expr: true*/
describe('isEnabled', function() {

before(h.setup());

it('should check if a single element is visible', function(done) {
this.client
.isEnabled('.waitForValueEnabled', function(err, isEnabled) {
assert.equal(err, null);
isEnabled.should.be.false;
})
.isEnabled('.waitForValueEnabledReverse', function(err, isEnabled) {
assert.equal(err, null);
isEnabled.should.be.true;
})
.call(done);
});

it('should check multiple elements are visible', function(done) {
this.client
.isEnabled('form input', function(err, isEnabled) {
assert.equal(err, null);
isEnabled.should.be.an.instanceOf(Array);
isEnabled.should.have.length(5);
isEnabled.should.containEql(true);
})
.call(done);
});

});

0 comments on commit 3b93c76

Please sign in to comment.