Enhanced nightwatchjs commands and assertions.
Usage
In nightwatch.json
add following content
"custom_assertions_path": [
"./node_modules/testarmada-nightwatch-extra/lib/assertions"
],
"custom_commands_path": [
"./node_modules/testarmada-nightwatch-extra/lib/commands"
]
If you're using this repo together with testarmada-magellan, your base test can inherit from the base test by
var BaseTest = require("testarmada-nightwatch-extra/lib/base-test-class");
For full example, please checkout boilerplate-nightwatch
Command vocabulary
If you're familiar with nightwatch
or are looking to translate nightwatch
examples into nightwatch-extra
, refer to the tables below for equivalent enhanced (i.e. more reliable) versions of nightwatch
commands and assertions.
All commands and assertions are fully compatible with nightwatchjs page object.
Enhanced command list
Nightwatch-Extra Equivalent | Nightwatch Command |
---|
clickAutomationEl("mybutton") | click("[data-automation-id="mybutton"]) |
clickEl(selector) | click(selector) |
getEl(selector) | waitForElementPresent or waitForElementVisible |
moveToEl(selector, xoffset, yoffset) | moveToElement |
setElValue(selector, value) | setValue(selector, value) |
getElValue(selector, callback) | getValue(selector) |
getEls(selector, callback) | elements(using, value, callback) |
setMaskedElValue(selector, value, [fieldLength]) | (no nightwatch equivalent) |
getPerformance(url) | Retrieves basic performance metrics using Navigation API (http://www.w3.org/TR/navigation-timing/) |
waitForElNotPresent(selector) | waitForElementNotPresent(selector) |
Enhanced assertion list
Nightwatch-Extra Equivalent | Nightwatch Assertion |
---|
assert.elContainsText(selector, regex or text) | assert.containsText(selector, text) |
assert.elNotContainsText(selector, text) | (no nightwatch equivalent) |
assert.selectorHasLength(selector, expectedLength) | (no nightwatch equivalent) |
assert.elLengthGreaterThan(selector, selectUsing, lengthToCompare) | (no nightwatch equivalent) |
As-is Supported Nightwatch Vocabulary
All Nightwatch commands and assertions are supported out of the box.
Supported Nightwatch Commands
Supported Nightwatch Assertions
Supported Node Assertions
fail
equal
notEqual
deepEqual
notDeepEqual
strictEqual
notStrictEqual
throws
doesNotThrow
ifError
Important migration notice
If you're migrating from magellan-nightwatch to nightwatch-extra, please follow the steps
- Delete
./node_modules/testarmada-magellan-nightwatch
from your project. - In
package.json
dependencies:{
"testarmada-magellan-nightwatch: VERSION <---- DELETE THIS LINE
"testarmada-nightwatch-extra: "^1.0.0" <---- ADD THIS LINE
}
- Run
npm install
again under your project root folder. - Make sure your
nightwatch.json
file has the following changes
"custom_commands_path":[
"./node_modules/testarmada-magellan-nightwatch/lib/commands" <---- DELETE THIS LINE
"./node_modules/testarmada-nightwatch-extra/lib/commands" <---- ADD THIS LINE
],
"custom_assertions_path":[
"./node_modules/testarmada-magellan-nightwatch/lib/assertions" <---- DELETE THIS LINE
"./node_modules/testarmada-nightwatch-extra/lib/assertions" <---- ADD THIS LINE
]
- Change parent of your base test class (if there is)
require("testarmada-magellan-nightwatch/lib/base-test-class"); <---- DELETE THIS LINE
require("testarmada-nightwatch-extra/lib/base-test-class"); <---- ADD THIS LINE