forked from levexis/grunt-selenium-webdriver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic CI tests that spin up a phantom client to help identify c…
…onfig issues
- Loading branch information
Paul Cook
committed
Jul 24, 2014
1 parent
258b115
commit 49a4b41
Showing
4 changed files
with
157 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
"contibutors": [ | ||
{ | ||
"name": "Paul Cook", | ||
"email": "[email protected]", | ||
"email": "[email protected]", | ||
"url": "https://github.com/levexis" | ||
} | ||
], | ||
|
@@ -24,7 +24,7 @@ | |
} | ||
], | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
"node": ">= 0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "grunt test" | ||
|
@@ -33,16 +33,21 @@ | |
"phantomjs": "~1.9.7-3" | ||
}, | ||
"devDependencies": { | ||
"selenium-webdriver": "~2.40.0", | ||
"grunt-contrib-jshint": "~0.10.0", | ||
"chai": "^1.9.1", | ||
"grunt": "~0.4.4", | ||
"grunt-contrib-clean": "~0.5.0", | ||
"grunt-contrib-connect": "^0.8.0", | ||
"grunt-contrib-jshint": "~0.10.0", | ||
"grunt-contrib-nodeunit": "~0.3.3", | ||
"grunt": "~0.4.4" | ||
"grunt-mocha-cli": "^1.9.0", | ||
"selenium-webdriver": "^2.42.1" | ||
}, | ||
"peerDependencies": { | ||
"grunt": "~0.4.4" | ||
}, | ||
"keywords": [ | ||
"gruntplugin","selenium","phantom" | ||
"gruntplugin", | ||
"selenium", | ||
"phantom" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Tests for grunt-selenium-webdriver, any problems are likely to be down to the relative install path of node modules on your system | ||
* run grunt test --stack for more info on | ||
*/ | ||
var chai = require('chai' ), | ||
webdriver = require('selenium-webdriver' ), | ||
FIXTURE = 'http://localhost:9000/index.html', | ||
expect = chai.expect, | ||
should = chai.should(); | ||
|
||
/** | ||
* creates a webdriver client | ||
* @param callBack or promise | ||
*/ | ||
function createClient( callBack) { | ||
// you can stick your saucelabs stuff here | ||
var serverConfig = 'http://127.0.0.1:4445/wd/hub', | ||
capabilities = { | ||
silent: true, // maybe output more for tests? | ||
browserName: 'phantomjs', | ||
javascriptEnabled: true, | ||
takesScreenshot: true, | ||
databaseEnabled: false, | ||
cssSelectorsEnabled:true, | ||
webStorageEnabled: true | ||
}; | ||
|
||
driver = new webdriver.Builder(). | ||
usingServer( serverConfig ). | ||
withCapabilities( capabilities). | ||
build(); | ||
if (typeof callBack === 'function') { | ||
return callBack (driver); | ||
} else if ( typeof callBack === 'object' && typeof callBack.resolve === 'function' ) { | ||
return callBack.resolve( driver ); | ||
} else { | ||
return driver; | ||
} | ||
} | ||
|
||
/** | ||
* gets inner html of main div element | ||
* @param callBack or promise | ||
*/ | ||
function getMain (driver, callBack) { | ||
driver.get( url ); | ||
var cont = driver.findElement( webdriver.By.id("main") ); | ||
cont.getAttribute('innerHTML').then( function ( html ) { | ||
callBack ( html ); | ||
}); | ||
} | ||
|
||
describe ('test phantom hub', function () { | ||
var _driver, | ||
setDriver = function ( driver ) { | ||
if (!driver) throw new Error ('driver not created'); | ||
_driver = driver; | ||
} | ||
before( function () { | ||
createClient ( setDriver ); | ||
} ); | ||
it ('should return a page with a main div saying page loaded', function (done) { | ||
expect ( _driver ).to.exist; | ||
driver.get( FIXTURE ); | ||
var main = driver.findElement( webdriver.By.id("main") ); | ||
main.getAttribute('innerHTML').then( function ( conts ) { | ||
conts.should.contain ('page loaded'); | ||
done(); | ||
}); | ||
}); | ||
it ('should change main div innerHTML to "main clicked" when clicked', function (done) { | ||
expect ( _driver ).to.exist; | ||
driver.get( FIXTURE ); | ||
var main = driver.findElement( webdriver.By.id("main") ); | ||
main.click() | ||
.then( function () { | ||
main.getAttribute('innerHTML').then( function ( conts ) { | ||
conts.should.contain( main ); | ||
done(); | ||
}); | ||
}); | ||
|
||
done(); | ||
}); | ||
}); |