buster-selenium
An extension for buster.js to make it easy to write functional tests with either selenium-webdriver, wd, and webdriverio.
This extensions is only for tests run in node environment.
Install
Installation is done using npm:
$ npm install buster-selenium
Usage
Add buster-selenium
extension and corresponding options, to the buster.js config file:
var config = moduleexports; config"Browser tests" = rootPath: "../" tests: "test/**/*.js" extensions: 'buster-selenium': // required, can be either selenium-webdriver or wd driver: 'selenium-webdriver'
Write the tests! Please check the documentation of the webdriver module you choose to use. Remember to quit the browser!
var buster = ; buster;
Go check out Examples of how to setup buster.js
config and tests.
Configuration
driver
- (string or function) - required, chooseselenium-webdriver
,wd
, orwebdriverio
strings or define a function that returns anything you want to use as the driver.config
- (object) - optional, configuration for the webdriver library. Each library is slightly different.timeout
- (number) - optional, defaults to 10000. Define how long a test runs before it timesout. Extend the time of your tests if the webdriver-driven browser takes a really long time to complete tasks.
Example
{ return 'someOtherWebdriver'config; } config: exampleOption: true exampleOption2: false
config
selenium-webdriver server
- (string) - url to the Selenium Server/Hub.desiredCapabilities
- (object) - define capabilities for the browser
Note: If phantomjs
is not found in $PATH
variable, it may be necessary to define the path in desiredCapabilities
.
Example
server: 'http://localhost:4444' desiredCapabilities: browserName: 'phantomjs' 'phantomjs.binary.path': './node_modules/.bin/phantomjs'
config
wd server
- (string or object) - url or parameters to the Selenium Server/Hub. Check wd browser-initialization docs for examplesdesiredCapabilities
- (object) - define capabilities for the browser
Note: Defining path to phantomjs
is not necessary.
Example
server: 'http://localhost:444' desiredCapabilities: browserName: 'phantomjs'
config
webdriverio Refer to webdriverio options docs for an explanation of the config
options.
Consider setting logLevel
property to "silent" when using xml
reporter.
webdriverio example)
Example (taken from a desiredCapabilities: browserName: 'chrome' version: '27' platform: 'XP' host: 'hub.browserstack.com' port: 80 user : processenvBROWSERSTACK_USERNAME key: processenvBROWSERSTACK_ACCESS_KEY logLevel: 'silent'
Usage
Every test will be extended with a webdriver
object with access to two properties.
driver
- (object) - Therequire
'd webdriver node module. Ex. require('wd'); or require('selenium-webdriver');browser
- (function) - A wrapper function around the webdrivers browser builder/initializer. Returns a browser session object with thedesiredCapbilities
config.
Example
// assume we are using selenium-webdriverbuster;
wd
Notes: wd
provides three (at the time of this writing) types of remote/browser objects. A regular continuation style, a promise, and a promise chain. To access them, pass the browser
function a string!
// Give me the promise remote/browser!thisbrowser = thiswebdriver; // or // Give me the promise chain remote/browser!thisbrowser = thiswebdriver; // or // Give me the regular continuation style remote/browser!thisbrowser = thiswebdriver;
Refer to wd docs
for more info.