Enhanced nightwatchjs commands and assertions for test automation for desktop web, mobile web, native app and hybrid app.
- A appium integrated base test for customization.
- An automatic wait for element to be visible (using
:visible
pseudo) before executing every nightwatch command or assertion (done by injecting sizzlejs). - A base command with wait-for-visible feature for further extension.
- A base assertion with wait-for-visible feature for further extension.
- An easy-to-use sizzlejs selector option.
- Sets of enhanced commands and assertions
- Option to launch appium programmatically in base test for easy debugging and test integration.
- A base command for native app test with wait-for-visible feature for further extension.
- A base assertion for native app test with wait-for-visible feature for further extension.
- Sets of enhanced commands and assertions for native app test.
In nightwatch.json
add following content
"custom_assertions_path": [
"./node_modules/testarmada-nightwatch-extra/lib/assertions",
"./node_modules/testarmada-nightwatch-extra/lib/assertions/mobile"
],
"custom_commands_path": [
"./node_modules/testarmada-nightwatch-extra/lib/commands",
"./node_modules/testarmada-nightwatch-extra/lib/commands/mobile"
]
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
For desktop and mobile web test, please refer to this page.
For iOS app test, please refer to this page.
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: "^3.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
Nightwatch-Extra@4
makes appium
an option besides selenium-server
, which means you can now use nightwatchjs to test in appium either locally or with a test environment provider, such as saucelabs, for mobile web or app test.
- Launch appium server automatically when tests need it
- Provide mobile commands for app test with appium
- Provide mobile assertions for app teset with appium
- Provide a base-mobile-base-command for easy extension
- Provide a base-mobile-base-assertion for easy extension
- Make sure your
nightwatch.json
file has the following changes
"custom_commands_path":[
"./node_modules/testarmada-nightwatch-extra/lib/commands",
"./node_modules/testarmada-nightwatch-extra/lib/commands/mobile"
],
"custom_assertions_path":[
"./node_modules/testarmada-nightwatch-extra/lib/assertions",
"./node_modules/testarmada-nightwatch-extra/lib/assertions/mobile"
]
- Add following code to your environment entry in
nightwatch.json
"selenium": {
"start_process": false
},
"appium": {
"start_process": true
}
Full example nightwatch.json
- baseTest.before
We've added a callback in before
. If you have a customized base test, please make sure you have the callback called in your customized baseTest.before
.
Please refer to Here as example.
- baseTest.after
after
needs to be called at the very first step in your customized baseTest.after
if you have one.
Please refer to Here as example.
- globals.js
To automatically handle appium server, a globals.js
is required to start appium in nightwatchjs's global before and stop appium in global after.
Please refer to the changes in nightwatch.json and globals.js for more info.