I user Webdriverio 6.3.6 with selenium-standalone-service 6.1.14 and all my tests run successfully locally but my test fails in bitbucket pipeline with the following error
<span>ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook</span><span>Error: not found: java</span>
<span>The same error happens for both firefox and chrome browser. How this can be fixed ?</span>
The entire log is below.
<span>(node:112) ExperimentalWarning: The fs.promises API is experimental</span><span>2020-08-07T19:55:34.208Z INFO @wdio/cli:launcher: Run onPrepare hook</span><span>2020-08-07T19:55:34.852Z ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook</span><span>Error: not found: java</span><span> at getNotFoundError (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:13:12)</span><span> at Function.whichSync [as sync] (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:134:9)</span><span> at start (/opt/atlassian/pipelines/agent/build/node_modules/selenium-standalone/lib/start.js:60:27)</span><span> at Promise (internal/util.js:275:30)</span><span> at new Promise (<anonymous>)</span><span> at start (internal/util.js:274:12)</span><span> at SeleniumStandaloneLauncher.onPrepare (/opt/atlassian/pipelines/agent/build/node_modules/@wdio/selenium-standalone-service/build/launcher.js:59:81)</span><span>Continue...</span><span>2020-08-07T19:55:34.854Z INFO @wdio/cli:launcher: Run onWorkerStart hook</span><span>2020-08-07T19:55:34.856Z INFO @wdio/local-runner: Start worker 0-0 with arg: ./wdio.conf.js,--suite,regression</span><span>[0-0] (node:125) ExperimentalWarning: The dns.promises API is experimental</span><span>[0-0] (node:125) ExperimentalWarning: The fs.promises API is experimental</span><span>[0-0] 2020-08-07T19:55:35.347Z INFO @wdio/local-runner: Run worker command: run</span><span>[0-0] 2020-08-07T19:55:35.356Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol</span><span>[0-0] RUNNING in chrome - /test/specs/regression/createMonitor.spec.js</span><span>[0-0] 2020-08-07T19:55:35.656Z INFO webdriverio: Initiate new session using the webdriver protocol</span><span>[0-0] 2020-08-07T19:55:35.659Z INFO webdriver: [POST] <a href="http://localhost:4444/wd/hub/session" target="_blank" rel="noopener nofollow noreferrer">http://localhost:4444/wd/hub/session</a></span><span>[0-0] 2020-08-07T19:55:35.660Z INFO webdriver: DATA { capabilities:</span><span> { alwaysMatch: { browserName: 'chrome' }, firstMatch: [ {} ] },</span><span> desiredCapabilities: { browserName: 'chrome' } }</span><span>[0-0] 2020-08-07T19:55:35.686Z ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:4444</span><span> at ClientRequest.request.once (/opt/atlassian/pipelines/agent/build/node_modules/got/dist/source/core/index.js:890:25)</span><span> at Object.onceWrapper (events.js:277:13)</span><span> at ClientRequest.emit (events.js:194:15)</span><span> at ClientRequest.EventEmitter.emit (domain.js:441:20)</span><span> at ClientRequest.origin.emit.args (/opt/atlassian/pipelines/agent/build/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)</span><span> at Socket.socketErrorListener (_http_client.js:392:9)</span><span> at Socket.emit (events.js:189:13)</span><span> at Socket.EventEmitter.emit (domain.js:441:20)</span><span> at emitErrorNT (internal/streams/destroy.js:82:8)</span><span> at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)</span><span> at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)</span><span>[0-0] 2020-08-07T19:55:35.687Z ERROR @wdio/runner: Error: Failed to create session.</span><span>Unable to connect to "<a href="http://localhost:4444/wd/hub" target="_blank" rel="noopener nofollow noreferrer">http://localhost:4444/wd/hub</a>", make sure browser driver is running on that address.</span><span>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.</span><span> at startWebDriverSession (/opt/atlassian/pipelines/agent/build/node_modules/webdriver/build/utils.js:45:11)</span><span> at process._tickCallback (internal/process/next_tick.js:68:7)</span><span>[0-0] Error: Failed to create session.</span><span>Unable to connect to "<a href="http://localhost:4444/wd/hub" target="_blank" rel="noopener nofollow noreferrer">http://localhost:4444/wd/hub</a>", make sure browser driver is running on that address.</span><span>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.</span><span>[0-0] FAILED in chrome - /test/specs/regression/createMonitor.spec.js</span><span>2020-08-07T19:55:35.797Z INFO @wdio/cli:launcher: Run onComplete hook</span><span>Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:01 </span><span>2020-08-07T19:55:35.798Z INFO @wdio/local-runner: Shutting down spawned worker</span><span>2020-08-07T19:55:36.050Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully</span><span>2020-08-07T19:55:36.050Z INFO @wdio/local-runner: shutting down</span><span>npm ERR! code ELIFECYCLE</span><span>npm ERR! errno 1</span><span>npm ERR! monitoring_tests@1.0.0 regression: `wdio <a href="https://bitbucket.org/postmanlabs/monitoring/src/99db48446cba1b3e293f216c14f3c80ef1802dd0/wdio.conf.js" target="_blank" rel="noopener noreferrer">./wdio.conf.js</a> --suite regression`</span><span>npm ERR! Exit status 1</span><span>npm ERR! </span><span>npm ERR! Failed at the monitoring_tests@1.0.0 regression script.</span><span>npm ERR! This is probably not a problem with npm. There is likely additional logging output above.</span><span>npm ERR! A complete log of this run can be found in:</span><span>npm ERR! /root/.npm/_logs/2020-08-07T19_55_36_063Z-debug.log</span><span>(node:112) ExperimentalWarning: The dns.promises API is experimental</span>