WebBot provides a beautiful way to automate web functional tests.
- Works with embedded phantomjs browser, any installed usual browser, or any available selenium grid hub
- Provides a clean frame to separate config data and scenario
- Provides a simple command line to execute web tests, easily integrate them into a CI, and create industrial testing projects
- Provides a browser object augmented with useful methods (see client-commands.js)
Globally :
# npm install -g webbot
# webbot
Or local to your project :
# cd myproject
# npm install webbot --save
# $(npm bin)/webbot
# mkdir myproject && cd myproject
- scenarii (this is where to place test scripts)
- mywebtest.js
- config (optionnal place for test scripts configurations)
- default (default environment)
- mywebtest.js or .json
- live (an environment called 'live')
- mywebtest.js or .json (will override default config)
- default (default environment)
var chai = require('chai')
, webbot = require('webbot')
, expect = chai.expect
, browser, scenario;
browser = webbot.getBrowser();
scenario = webbot.getScenario();
describe('Simple web test', function () {
after(function (done) {
browser
.end(done);
});
it('should check web page title', function (done) {
browser
.log('Connect to %s', scenario.config.url)
.url(scenario.config.url)
.log('Check page title : %s', scenario.config.title)
.getTitle(function (err, value) {
expect(err).to.be.undefined;
expect(value).to.equal(scenario.config.title);
})
.call(done);
});
});
{ "timeout": 10000 }
{ "url": "http://www.google.com", "title": "Google" }
# webbot -f
mywebtest
# webbot -e live -s mywebtest
webbot:info webbot - using browser : phantomjs [platform : ANY] +0ms
Simple web test
webbot:info browser - #1 - Connect to http://www.google.com +1s
webbot:info browser - #2 - Check page title : Google +827ms
✓ should home page (1782ms)
1 passing (2s)
- --dir (-d) : base directory of scenarii and configuration files, it should respect directory structure (default : current dir)
- --env (-e) : environnement name to use for configuration, it should be a child of config directory where to find configuration json files (example : live)
- --scenario (-s) : scenario to execute, it should be placed under scenarii directory (example : mywebtest)
- --options (-o) : webdriver browser options, in JSON string format, as specified in WebdriverIO remote options
- --commands (-c) : extra client commands module to register, it should be a collection of functions to add to the browser object as specified in WebdriverIO custom commands (example : lib/myCustomCommands)
- --loglevel (-l) : log level to enable (error|warn|info|debug|trace)
# webbot -e live -s mywebtest -l trace
# webbot -e live -s mywebtest -o '{"desiredCapabilities":{"browserName": "firefox"}}'
# webbot -e live -s mywebtest -o '{"desiredCapabilities":{"browserName": "chrome"}}'
VM is registered to a selenium hub server
# webbot -e live -s mywebtest -o '{"desiredCapabilities":{"browserName": "internet explorer","version":"11"},"host":"myseleniumserver.com","port":4445}' -l trace
Specified module provides functions used as extra client commands
# cd mycustomproject
# webbot -e live -s mywebtest -c lib/myCustomCommands
WebBot is mainly powered by WebdriverIO and Mocha
Enjoy !