0.0.17 • Published 2 years ago
nightwatch-mobile-helper v0.0.17
@nightwatch/mobile-helper
Setup for mobile-web testing
Android
From your Nightwatch project's root dir, run:
npx @nightwatch/mobile-helper android
Answer a few questions related to your requirements:
- It will verify if all the requirements are being met.
- If some requirements are not being met, it will ask whether to download and setup those requirements:
- Voila :tada: Your setup is now complete. (If something fails, follow the instructions and re-run the command.)
Add the following env configuration to your
nightwatch.conf.js
ornightwatch.json
file:"test_settings": { // other envs above this line 'android.chrome': { desiredCapabilities: { browserName: 'chrome', 'goog:chromeOptions': { w3c: true, args: [ //'--no-sandbox', //'--ignore-certificate-errors', //'--allow-insecure-localhost', //'--headless' ], androidPackage: 'com.android.chrome', // add the device serial to run tests on, if multiple devices are online // Run command: `$ANDROID_HOME/platform-tools/adb devices` // androidDeviceSerial: '' }, }, webdriver: { start_process: true, server_path: 'chromedriver-mobile/chromedriver', cli_args: [ // --verbose ] } }, 'android.firefox': { desiredCapabilities: { browserName: 'firefox', acceptInsecureCerts: true, 'moz:firefoxOptions': { args: [ // '-headless', // '-verbose' ], androidPackage: 'org.mozilla.firefox', // add the device serial to run tests on, if multiple devices are online // Run command: `$ANDROID_HOME/platform-tools/adb devices` // androidDeviceSerial: 'ZD2222W62Y' } }, webdriver: { start_process: true, server_path: '', cli_args: [ // very verbose geckodriver logs // '-vv' ] } }, }
If testing on real-device:
- Make sure latest version of Chrome/Firefox browsers are installed. If not, install them from Google Play Store.
- Turn on USB Debugging on your Android Device and connect it to your system via data cable.
- If testing on emulator, make sure
chromedriver-mobile/chromedriver
is present in your Nightwatch project's root dir. If not present, re-run the command in first step. - Run your nightwatch tests on Android mobile browsers:
# for firefox npx nightwatch --env android.firefox # for chrome npx nightwatch --env android.chrome