Everything you need for selenium testing in node.js.
There are two parts: the library and the runner.
The library provides you with the
setup() function which returns a driver that is instrumented to make your tests simple, semantic, and easy to use. Among other things, it is automatically initialized in a
before() clause, destroyed in an
after() clause, and will even fire up an instance of your app & a webdriver server if you need them!
The runner is configured with a
selenium.json file, and will run your mocha test files in series or in parallel, for any number of browsers. Installing it with
npm install -g mocha-selenium will give you the
mocha-selenium command on your path.
Has a bunch of options. Some of the options are default to ENV variables if they are present. Read the docs for a thorough description.
Here's an example:
var expect =b =;
In addition to the normal wd methods, there are the following:
On the current page, if the cookie by the name of
name with value
value does not exist, set the cookie and refresh the page.
If value is a function, it is called with the current value of the cookie. If it returns a value other than the current cookie value, the cookie is set to that value.
Data is a map of
"input name": "value to type". If
given, only inputs that are children of the given selector will be
filled in. Otherwise, the first input in the document with the given
name will be populated.
b.baseUrl + url.
The following suffixes are available for these methods, mirroring the
ByClassName, ByCssSelector, ById, ByName, ByLinkText, ByPartialLinkText, ByTagName, ByXPath, ByCss.
I will use the
ByCss suffix for demonstration.
Run your mocha selenium tests in parallel in mutliple browsers.
Usage: mocha-selenium [options]Options:-h, --help output usage information-V, --version output the version number-e, --environment [env] Pick the environment to run (host + browsers). Default: local-p, --parallel Run the tests in parallel. Default: false-c, --config [file] Specify the config file. Default: ./selenium.json
files: // filename or glob, or list of filenames or globsenvs: // a map of [envname] to an environment definition.local: browserdef ... ORbrowsers: browserdef ...inherits: // name or list of names of other environemnts. Their// browserdefs will be appended to the current env.// if no hostname is given, mocha-selenium will start its own// selenium drivers. Currently phantomjs and chrome are supportedhostname: "ondemand.saucelabs.com"port: 80auth:type: 'plain'username: 'MyName'password: 'secret'ORtype: 'env' // the username and password are environmental variablesusername: 'SAUCE_USERNAME'password: 'SAUCE_ACCESS_KEY'otherenv: ......
["browsername", "version", "platform"]ex:["internet explorer", "8", "Windows XP"]