Webdriverio Cucumberjs tests for a React Native app fails on AWS Device Farm - Socket hang up - react-native

I'm writing End-to-ends tests for a React Native app using WebdriverIo, Appium and Cucumberjs and deploying the tests on the AWS Device Farm.
The tests are working fine both on the Android simulator and on an actual real device. Though, on AWS, it throws errors such as (node:3113) DeprecationWarning: Got: "options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized" and RequestError: socket hang up. This is shown in more detail below:
[DeviceFarm] echo "Start Appium Node test"
Start Appium Node test
[DeviceFarm] npm run only-one-test-aws
> e2e-cucumber-wdio-appium#1.0.0 only-one-test-aws /tmp/scratch0EgKio.scratch/test-packageFvDXet
> npx wdio ./wdio.android.conf.js --spec ./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
Execution of 1 spec files started at 2020-06-04T18:23:19.220Z
2020-06-04T18:23:19.223Z INFO #wdio/cli:launcher: Run onPrepare hook
2020-06-04T18:23:19.254Z INFO #wdio/cli:launcher: Run onWorkerStart hook
2020-06-04T18:23:19.256Z INFO #wdio/local-runner: Start worker 0-0 with arg: ./wdio.android.conf.js,--spec,./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
[0-0] 2020-06-04T18:23:20.961Z INFO #wdio/local-runner: Run worker command: run
[0-0] 2020-06-04T18:23:21.062Z DEBUG #wdio/local-runner:utils: init remote session
[0-0] 2020-06-04T18:23:21.095Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol
[0-0] RUNNING in undefined - /features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
[0-0] 2020-06-04T18:23:22.697Z DEBUG #wdio/local-runner:utils: init remote session
[0-0] 2020-06-04T18:23:22.714Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2020-06-04T18:23:22.717Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
[0-0] 2020-06-04T18:23:22.717Z INFO webdriver: DATA {
capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
desiredCapabilities: {}
}
[0-0] (node:3113) DeprecationWarning: Got: "options.rejectUnauthorized" is now deprecated, please use "options.https.rejectUnauthorized"
[0-0] 2020-06-04T18:24:52.853Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.
[0-0] 2020-06-04T18:24:52.856Z INFO webdriver: Retrying 1/3
[0-0] 2020-06-04T18:24:52.857Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
[0-0] 2020-06-04T18:24:52.857Z INFO webdriver: DATA {
capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
desiredCapabilities: {}
}
[0-0] 2020-06-04T18:24:54.004Z DEBUG webdriver: request failed due to response error: unknown error
[0-0] 2020-06-04T18:24:54.004Z WARN webdriver: Request failed with status 500 due to An unknown server-side error occurred while processing the command. Original error: end of central directory record signature not found
[0-0] 2020-06-04T18:24:54.005Z INFO webdriver: Retrying 2/3
[0-0] 2020-06-04T18:24:54.014Z INFO webdriver: [POST] http://127.0.0.1:4723/wd/hub/session
[0-0] 2020-06-04T18:24:54.014Z INFO webdriver: DATA {
capabilities: { alwaysMatch: {}, firstMatch: [ {} ] },
desiredCapabilities: {}
}
[0-0] 2020-06-04T18:24:54.030Z ERROR webdriver: RequestError: socket hang up
at ClientRequest.<anonymous> (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/got/dist/source/core/index.js:817:25)
at Object.onceWrapper (events.js:417:26)
at ClientRequest.emit (events.js:322:22)
at ClientRequest.EventEmitter.emit (domain.js:482:12)
at ClientRequest.origin.emit (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/#szmarczak/http-timer/dist/source/index.js:39:20)
at Socket.socketOnEnd (_http_client.js:453:9)
at Socket.emit (events.js:322:22)
at Socket.EventEmitter.emit (domain.js:482:12)
at endReadableNT (_stream_readable.js:1187:12)
at connResetException (internal/errors.js:608:14)
at Socket.socketOnEnd (_http_client.js:453:23)
at Socket.emit (events.js:322:22)
at Socket.EventEmitter.emit (domain.js:482:12)
at endReadableNT (_stream_readable.js:1187:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
[0-0] 2020-06-04T18:24:54.031Z ERROR #wdio/runner: Error: Failed to create session.
socket hang up
at startWebDriverSession (/tmp/scratch0EgKio.scratch/test-packageFvDXet/node_modules/webdriver/build/utils.js:45:11)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[0-0] Error: Failed to create session.
socket hang up
2020-06-04T18:24:54.147Z DEBUG #wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILED in undefined - /features/recarga/verificacacaoCodigoDeAcessoInvalido.feature
2020-06-04T18:24:54.148Z INFO #wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:01:34
2020-06-04T18:24:54.164Z INFO #wdio/local-runner: Shutting down spawned worker
2020-06-04T18:24:54.416Z INFO #wdio/local-runner: Waiting for 0 to shut down gracefully
2020-06-04T18:24:54.417Z INFO #wdio/local-runner: shutting down
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! e2e-cucumber-wdio-appium#1.0.0 only-one-test-aws: `npx wdio ./wdio.android.conf.js --spec ./features/recarga/verificacacaoCodigoDeAcessoInvalido.feature`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the e2e-cucumber-wdio-appium#1.0.0 only-one-test-aws script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/device-farm/.npm/_logs/2020-06-04T18_24_54_506Z-debug.log
[DEVICEFARM] ########### Entering phase post_test ###########
[DEVICEFARM] ########### Finish executing testspec ###########
[DEVICEFARM] ########### Setting upload permissions ###########
[DEVICEFARM] Tearing down your device. Your tests report will come shortly.
I also tried this question's solution by installing the webdriverio and #wdio/cli dependencies globally, though it did not work to me.
PS: I've already been able to successfully perform tests on the AWS Device Farm using webdriverio and cucumber. Though, these errors started to show up for me recently and I still have no clue on how to solve them.
Can someone please help me with this?

Related

CoreUi - why nightwatch cannot run e2e tests?

I want to start working with CoreUi Admin template and create project containing unit and e2e testing.
In the begining, I install CoreUi like shown in documentation:
git clone https://github.com/coreui/coreui-free-vue-admin-template.git CoreUI-Vue
cd CoreUI-Vue
npm install
Everything is ok. Now I want to run whole unit and e2e tests:
npm run test:unit
npm run test:e2e
All unit tests run properly. But when I run e2e test I got the following errors:
> #coreui/coreui-free-vue-admin-template#3.1.4 test:e2e
> vue-cli-service test:e2e
INFO Starting development server...
[BABEL] Note: The code generator has deoptimised the styling of /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#coreui/vue/dist/coreui-vue.common.js as it exceeds the max of 500KB.
WARNING Compiled with 2 warnings 2:47:38 PM
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/app.10fee0d6.css (383 KiB) js/chunk-28d6db65.e7636129.js (488 KiB)
js/chunk-2d0a400c.650c6f3a.js (3.37 MiB) js/chunk-2d0ae5e6.22010046.js (390 KiB)
js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
js/chunk-vendors.03b8fe62.js (687 KiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.07 MiB)
js/chunk-vendors.03b8fe62.js
css/app.10fee0d6.css
js/app.94002fbe.js
App running at:
- Local: http://localhost:8080/
- Network: http://172.31.33.121:8080/
App is served in production mode.
Note this is for preview or E2E testing only.
INFO Running end-to-end tests ...
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)
✖ test
An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally." at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
SKIPPED:
- CoreUI Vue e2e tests
ERROR Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
bagsiur#DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$
bagsiur#DESKTOP-718MBR1:~/Projects/B2B/test-coreui/CoreUI-Vue$ npm run test:e2e
> #coreui/coreui-free-vue-admin-template#3.1.4 test:e2e
> vue-cli-service test:e2e
INFO Starting development server...
WARNING Compiled with 2 warnings 3:06:39 PM
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/app.10fee0d6.css (383 KiB)
js/chunk-28d6db65.e7636129.js (488 KiB)
js/chunk-2d0a400c.650c6f3a.js (3.37 MiB)
js/chunk-2d0ae5e6.22010046.js (390 KiB)
js/chunk-2d237b34.468fc7b7.js (1.36 MiB)
js/chunk-vendors.03b8fe62.js (687 KiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.07 MiB)
js/chunk-vendors.03b8fe62.js
css/app.10fee0d6.css
js/app.94002fbe.js
App running at:
- Local: http://localhost:8080/
- Network: http://172.31.33.121:8080/
App is served in production mode.
Note this is for preview or E2E testing only.
INFO Running end-to-end tests ...
[Test] Test Suite
=================
⚠ Error connecting to localhost on port 9515.
_________________________________________________
TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (348ms)
✖ test
An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally." at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
SKIPPED:
- CoreUI Vue e2e tests
ERROR Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
Error: Command failed: /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/nightwatch/bin/nightwatch --config /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/#vue/cli-plugin-e2e-nightwatch/nightwatch.config.js --env chrome
at makeError (/home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:174:9)
at /home/bagsiur/Projects/B2B/test-coreui/CoreUI-Vue/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I work on wsl2 and Debian. My node.js version is v13.14.0 and npm is 7.12.1. I installed chromedriver in version: ChromeDriver 2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706) and last stable google chrome: google-chrome-stable 90.0.4430.212-1
What do I miss? Where could be the cause of the error in running e2e tests?
#UPDATE: I put the configuration of Nightwatch.conf.json:
// http://nightwatchjs.org/gettingstarted#settings-file
const path = require('path')
const deepmerge = require('deepmerge')
const chromedriver = require('chromedriver')
// user may have not installed geckodriver
let geckodriver = {}
try {
geckodriver = require('geckodriver')
} catch (e) {}
const userOptions = JSON.parse(process.env.VUE_NIGHTWATCH_USER_OPTIONS || '{}')
const useSelenium = process.env.VUE_NIGHTWATCH_USE_SELENIUM === '1'
const startHeadless = process.env.VUE_NIGHTWATCH_HEADLESS === '1'
const concurrentMode = process.env.VUE_NIGHTWATCH_CONCURRENT === '1'
const chromeArgs = []
const geckoArgs = []
if (startHeadless) {
chromeArgs.push('headless')
geckoArgs.push('--headless')
}
const defaultSettings = {
src_folders: ['tests/e2e/specs'],
output_folder: 'tests/e2e/reports',
page_objects_path: 'tests/e2e/page-objects',
custom_assertions_path: 'tests/e2e/custom-assertions',
custom_commands_path: 'tests/e2e/custom-commands',
globals_path: path.resolve('tests/e2e/globals.js'),
test_workers: concurrentMode,
test_settings: {
default: {
detailed_output: !concurrentMode,
launch_url: '${VUE_DEV_SERVER_URL}'
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
w3c: false,
args: chromeArgs
}
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
alwaysMatch: {
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: geckoArgs
}
}
},
webdriver: useSelenium ? {} : {
server_path: geckodriver.path,
port: 4444
}
}
}
}
const baseSettings = deepmerge(defaultSettings, webdriverServerSettings())
module.exports = deepmerge(baseSettings, adaptUserSettings(userOptions))
function adaptUserSettings (settings) {
// The path to nightwatch external globals file needs to be made absolute
// if it is supplied in an additional config file, due to merging of config files
if (settings.globals_path) {
settings.globals_path = path.resolve(settings.globals_path)
}
return settings
}
function webdriverServerSettings () {
if (useSelenium) {
return {
selenium: {
start_process: true,
host: '127.0.0.1',
port: 4444,
server_path: require('selenium-server').path,
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.gecko.driver': geckodriver.path
}
}
}
}
return {
webdriver: {
start_process: true,
port: 9515,
server_path: chromedriver.path
}
}
}
Version mismatch of chromedriver and chrome is the most common reason of e2e failing like this.
ChromeDriver 2.41 supports Chrome v67-69
your google-chrome-stable 90.0.4430 needs ChromeDriver 90.0.4430

webdriverIO and saucelab integration not working

When I tried connecting webdriverIO with sauce labs, I'm getting error as
I'm using sauce service
$ ./node_modules/.bin/wdio ./config/int.wdio.conf.js
Execution of 1 spec files started at 2020-08-30T20:11:14.720Z
2020-08-30T20:11:14.768Z INFO #wdio/cli:launcher: Run onPrepare hook
2020-08-30T20:11:14.770Z INFO #wdio/cli:launcher: Run onWorkerStart hook
2020-08-30T20:11:14.772Z INFO #wdio/local-runner: Start worker 0-0 with arg: ./config/int.wdio.conf.js
[0-0] 2020-08-30T20:11:15.414Z INFO #wdio/local-runner: Run worker command: run
[0-0] 2020-08-30T20:11:15.422Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol
[0-0] RUNNING in chrome - /e2e/test/login.int.spec.js
[0-0] 2020-08-30T20:11:15.704Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2020-08-30T20:11:15.706Z INFO webdriver: [POST] https://ondemand.saucelabs.com/wd/hub/session
[0-0] 2020-08-30T20:11:15.706Z INFO webdriver: DATA {
capabilities: {
alwaysMatch: { browserName: 'chrome', acceptInsecureCerts: true },
firstMatch: [ {} ]
},
desiredCapabilities: { browserName: 'chrome', acceptInsecureCerts: true }
}
[0-0] 2020-08-30T20:11:15.733Z ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:443
at ClientRequest.<anonymous> (/node_modules/got/dist/source/core/index.js:891:25)
at Object.onceWrapper (events.js:418:26)
at ClientRequest.emit (events.js:323:22)
at ClientRequest.EventEmitter.emit (domain.js:482:12)
at ClientRequest.origin.emit (/test/node_modules/#szmarczak/http-timer/dist/source/index.js:39:20)
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:311:20)
at TLSSocket.EventEmitter.emit (domain.js:482:12)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
[0-0] 2020-08-30T20:11:15.733Z ERROR #wdio/runner: Error: Failed to create session.
Unable to connect to "https://ondemand.saucelabs.com:443/wd/hub", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
at startWebDriverSession (/test/node_modules/webdriver/build/utils.js:45:11)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[0-0] Error: Failed to create session.
Unable to connect to "https://ondemand.saucelabs.com:443/wd/hub", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
[0-0] FAILED in chrome - /e2e/test/login.int.spec.js
2020-08-30T20:11:15.848Z INFO #wdio/cli:launcher: Run onComplete hook
Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:01
2020-08-30T20:11:15.849Z INFO #wdio/local-runner: Shutting down spawned worker
2020-08-30T20:11:16.102Z INFO #wdio/local-runner: Waiting for 0 to shut down gracefully
2020-08-30T20:11:16.102Z INFO #wdio/local-runner: shutting down
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
my wdio.config.js looks like
exports.config = {
runner: 'local',
user: 'test123',
key: '65434d10-276f-4305-adb4-93a39848d445',
region: 'us',
specs: [
'./e2e/test/*.int.spec.js'
],
exclude: [
'./e2e/test/*.prod.spec.js',
'./e2e/test/*.ie.int.spec.js'
],
maxInstances: 1,
capabilities: [
{
maxInstances: 1,
browserName: 'chrome',
acceptInsecureCerts: true
}
],
logLevel: 'info',
bail: 0,
baseUrl: 'https://www.google.com',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: ['sauce'],
framework: 'mocha',
reporters: ['mochawesome'],
mochaOpts: {
ui: 'bdd',
timeout: 60000
}
}
any idea how to fix this...

Running "vue ui" on Windows Subsystem For Linux (WSL) will not work

An error will get generated when running:
vue ui
vue ui
🚀 Starting GUI...
🌠 Ready on http://localhost:8001
events.js:287
throw er; // Unhandled 'error' event
^
Error: spawn cmd.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd.exe',
path: 'cmd.exe',
spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:8001' ]
}
Expected to get an app running on port localhost:8001, but the above error gets generated.
The reason is because it is trying to open a browser window from inside WSL terminal.
Instead, do the following:
vue ui --headless
This will avoid running the cmd.exe to open a browser and instead run the app on port 8001. You'll have to open a browser manually to http://localhost:8001

Nightwatch.js doesn't work on Linux server

I edited the question.
If someone can help me to understand why my test doesn't work, it would be very appreciated.
It seems to me that Selenium server starts and Chromedriver starts (please take a look at 'selenium-debug.log' section), but tests scripts are not executed.
My codes work on my Mac, but I don't know why they don't on a Linux server.
My codes are here: https://github.com/watarumohawk/nightwatchjs-e2e
On the server, node is v7.2.0, and npm is v4.0.5. So I installed these versions on my Mac, but I still can't reproduce the issue on my Mac.
On my Mac, 'npm run test:amazon' and 'node_modules/nightwatch/bin/nightwatch' work.
On the Linux server, I tried this:
node_modules/nightwatch/bin/nightwatch
$ node_modules/nightwatch/bin/nightwatch
Starting selenium server in parallel mode... started - PID: 29825
Started child process for: amazon/amazon-top
>> amazon/amazon-top finished.
npm run test:amazon
$ npm run test:amazon
> Nightwatch-e2e#1.1.0 test:amazon /home/foo/work/hoge/nightwatchjs-e2e
> nightwatch --group amazon
Starting selenium server in parallel mode... started - PID: 30066
Started child process for: amazon/amazon-top
>> amazon/amazon-top finished.
npm ERR! Linux 3.10.0-327.4.5.el7.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test:amazon"
npm ERR! node v7.2.0
npm ERR! npm v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! Nightwatch-e2e#1.1.0 test:amazon: `nightwatch --group amazon`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Nightwatch-e2e#1.1.0 test:amazon script 'nightwatch --group amazon'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Nightwatch-e2e package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nightwatch --group amazon
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Nightwatch-e2e
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls Nightwatch-e2e
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/foo/work/hoge/nightwatchjs-e2e/npm-debug.log
Settings:
package.json
{
......
"scripts": {
"test": "nightwatch",
"test:amazon": "nightwatch --group amazon"
},
"dependencies": {
"chai-nightwatch": "^0.1.1",
"chromedriver": "^2.32.3",
"nightwatch": "^0.9.16",
"selenium-server-standalone-jar": "3.6.0"
},
"devDependencies": {}
}
nightwatch.json
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"test_workers" : {"enabled" : true, "workers" : "auto"},
"selenium" : {
"start_process" : true,
"server_path" : "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.6.0.jar",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "node_modules/chromedriver/lib/chromedriver/chromedriver",
"webdriver.ie.driver" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"firefox_profile": false,
"chrome_driver" : "",
"screenshots" : {
"enabled" : true,
"path" : "screenshots",
"on_failure": true,
"on_error": false
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": ["--headless","--window-size=1920,1080"]
},
"use_xpath": false
}
}
}
}
Logs:
selenium-debug.log
15:31:22.180 INFO - Selenium build info: version: '3.6.0', revision: '6fbf3ec767'
15:31:22.180 INFO - Launching a standalone Selenium Server
2017-10-19 15:31:22.193:INFO::main: Logging initialized #159ms to org.seleniumhq.jetty9.util.log.StdErrLog
15:31:22.228 INFO - Driver class not found: com.opera.core.systems.OperaDriver
15:31:22.247 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
15:31:22.247 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
15:31:22.247 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
15:31:22.264 INFO - Using the passthrough mode handler
2017-10-19 15:31:22.281:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-10-19 15:31:22.297:WARN:osjs.SecurityHandler:main: ServletContext#o.s.j.s.ServletContextHandler#eec5a4a{/,null,STARTING} has uncovered http methods for path: /
2017-10-19 15:31:22.300:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#eec5a4a{/,null,AVAILABLE}
2017-10-19 15:31:22.310:INFO:osjs.AbstractConnector:main: Started ServerConnector#9660f4e{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-10-19 15:31:22.311:INFO:osjs.Server:main: Started #278ms
15:31:22.311 INFO - Selenium Server is up and running
2017-10-19 15:31:22.528:INFO:osjshC.ROOT:qtp1910163204-11: org.openqa.selenium.remote.server.WebDriverServlet-28d25987: Initialising WebDriverServlet
15:31:22.552 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
15:31:22.553 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#41c87be0
15:31:22.555 INFO - /session: Executing POST on /session (handler: BeginSession)
15:31:22.587 INFO - Capabilities are: Capabilities {acceptSslCerts=true, name=Amazon / Amazon Top, browserName=chrome, javascriptEnabled=true, use_xpath=false, chromeOptions={args=[--headless, --window-size=1920,1080]}, platformName=ANY, platform=ANY, }
15:31:22.587 INFO - Capabilities {acceptSslCerts=true, name=Amazon / Amazon Top, browserName=chrome, javascriptEnabled=true, use_xpath=false, chromeOptions={args=[--headless, --window-size=1920,1080]}, platformName=ANY, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
15:31:22.588 INFO - Capabilities {acceptSslCerts=true, name=Amazon / Amazon Top, browserName=chrome, javascriptEnabled=true, use_xpath=false, chromeOptions={args=[--headless, --window-size=1920,1080]}, platformName=ANY, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
15:31:22.588 INFO - Capabilities {acceptSslCerts=true, name=Amazon / Amazon Top, browserName=chrome, javascriptEnabled=true, use_xpath=false, chromeOptions={args=[--headless, --window-size=1920,1080]}, platformName=ANY, platform=ANY, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4) on port 27120
Only local connections are allowed.
npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test:amazon' ]
2 info using npm#4.0.5
3 info using node#v7.2.0
4 verbose run-script [ 'pretest:amazon', 'test:amazon', 'posttest:amazon' ]
5 info lifecycle Nightwatch-e2e#1.1.0~pretest:amazon: Nightwatch-e2e#1.1.0
6 silly lifecycle Nightwatch-e2e#1.1.0~pretest:amazon: no script for pretest:amazon, continuing
7 info lifecycle Nightwatch-e2e#1.1.0~test:amazon: Nightwatch-e2e#1.1.0
8 verbose lifecycle Nightwatch-e2e#1.1.0~test:amazon: unsafe-perm in lifecycle true
9 verbose lifecycle Nightwatch-e2e#1.1.0~test:amazon: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/foo/work/hoge/nightwatchjs-e2e/node_modules/.bin:/home/foo/.pyenv/shims:/home/foo/.pyenv/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/foo/.local/bin:/home/foo/bin
10 verbose lifecycle Nightwatch-e2e#1.1.0~test:amazon: CWD: /home/foo/work/hoge/nightwatchjs-e2e
11 silly lifecycle Nightwatch-e2e#1.1.0~test:amazon: Args: [ '-c', 'nightwatch --group amazon' ]
12 silly lifecycle Nightwatch-e2e#1.1.0~test:amazon: Returned: code: 1 signal: null
13 info lifecycle Nightwatch-e2e#1.1.0~test:amazon: Failed to exec test:amazon script
14 verbose stack Error: Nightwatch-e2e#1.1.0 test:amazon: `nightwatch --group amazon`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:885:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid Nightwatch-e2e#1.1.0
16 verbose cwd /home/foo/work/hoge/nightwatchjs-e2e
17 error Linux 3.10.0-327.4.5.el7.x86_64
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test:amazon"
19 error node v7.2.0
20 error npm v4.0.5
21 error code ELIFECYCLE
22 error Nightwatch-e2e#1.1.0 test:amazon: `nightwatch --group amazon`
22 error Exit status 1
23 error Failed at the Nightwatch-e2e#1.1.0 test:amazon script 'nightwatch --group amazon'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the Nightwatch-e2e package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error nightwatch --group amazon
23 error You can get information on how to open an issue for this project with:
23 error npm bugs Nightwatch-e2e
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls Nightwatch-e2e
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Running Selenium webdriver-manager from Gradle

I am trying to start Selenium from Gradle in order to run Protractor tests.
Here is my Gradle script:
//main task to run protractor tests
task uiTests << {
println "Starting protractor tests"
}
//start Selenium server
task startSelenium << {
println "Starting Selenium..."
ant.exec(executable: '/bin/bash', spawn: true) {
arg(value:'webdriver-manager')
arg(value:'start')
}
}
//run protractor
task runProtractor(type: Exec) {
commandLine 'protractor', 'bignibou-client/protractor.conf.js'
}
//start selenium, then run protractor
uiTests.dependsOn([startSelenium, runProtractor])
However, the output seems to indicate that the Selenium process has not being started:
:runProtractor
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
at ClientRequest.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172:16)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:259:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1250:8)
at doNTCallback2 (node.js:429:9)
at process._tickCallback (node.js:343:17)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at [object Object].Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:445:22)
at [object Object].DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
at [object Object].Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.js:182:37)
at /usr/local/lib/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:525:49
[launcher] Process exited with error code 1
:runProtractor FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':runProtractor'.
> Process 'command 'protractor'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Can anyone please provide informed tips and guidance?
By referring the webdriver-manager script directly as shown below sorted the issue:
//main task to run protractor tests
task uiTests << {
println "Starting protractor tests"
}
//start Selenium server
task startSelenium << {
println "Starting Selenium..."
ant.exec(executable: 'webdriver-manager', spawn: true) {//CHANGED!!
arg(value: 'start')
}
}
//run protractor
task runProtractor(type: Exec) {
commandLine 'protractor', 'bignibou-client/protractor.conf.js'
}
//start selenium, then run protractor
uiTests.dependsOn([startSelenium, runProtractor])