selenium-runner
Run a [{url+JSTest}, ..] combo in selenium grid, in parallel, in multiple browsers.
Basically, this module will launch a set of tests, in the browsers you want. A test is defined by a URL to visit and a JavaScript callback to execute when the page is ready.
npm installnode example
Writing tests
We want to check the <title>
of http://www.google.com in multiple browsers.
We will run the same test on http://www.yahoo.com and it will fail because the title
is different.
Test file
Write your test file, it's a callback that will get a ready browser object.
check-title.js
module { browsertitle { if err !== null ; if title === 'Google' ; else ; };}
Some configuration
- remoteCfg: Where is the selenium grid, you can also use saucelabs
- browsers: On which browsers to launch every test
- concurrency: How many tests a browser can launch in parallel
config.json
Run them all!
launcher.js
var seleniumRunner = ; // tests to runvar tests = url: 'http://www.google.com' exec: url: 'http://www.yahoo.com' exec: ; var config = ; // launch tests; // For each browser, you get the result of calling your test (check-title) here// You always get the context: {url: 'http://', browser: {browserName: '', version: }} { console;} // Called when all tests have finished/or an error popped while connecting to the grid// It will not get called when an error is emitted from a test { console;}
Results
-> % node exampleYou should get 4 test callbacks and one end callbackA test finished