I'm trying to run a webdriver.io test suite from the VS Code debugger but it is failing with the error message:
ERROR @wdio/cli:utils: A service failed in the 'onPrepare' hook
Error: not found: java
at getNotFoundError (/Users/andrew/projects/rod-licensing-tests/packages/frontend-acceptance-tests/node_modules/selenium-standalone/node_modules/which/which.js:10:17)
How do I get round this? From looking at similar issues on the web, I've tried the following with the same results:
npm install
npm install java
./node_modules/.bin/selenium-standalone install
launch.json
config: "JAVA_HOME": "/usr/libexec/java_home"
The tests do run successfully using Docker, but I'd ideally want to run this from the IDE too so that I can quickly start and debug them. Also, my colleague can run the same tests using config in IntelliJ IDE Ultimate but I feel this should be possible in VS Code too.
This is the current content of my launch.json
file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch via NPM",
"type": "pwa-node",
"args": [
"conf/local.conf.js",
"--logLevel trace"
],
"cwd": "${workspaceFolder}/packages/frontend-acceptance-tests",
"env": {
"JAVA_HOME": "/usr/libexec/java_home",
"SERVICE_URL": "[redacted]",
"OAUTH_AUTHORITY_HOST_URL": "[redacted]",
"OAUTH_TENANT": "[redacted]",
"OAUTH_CLIENT_ID": "[redacted]",
"OAUTH_CLIENT_SECRET": "[redacted]",
"OAUTH_SCOPE": "[redacted]",
"DYNAMICS_API_PATH": "[redacted]",
"DYNAMICS_API_VERSION": "9.1"
},
"request": "launch",
"runtimeExecutable": "${workspaceFolder}/packages/frontend-acceptance-tests/node_modules/.bin/wdio",
"runtimeVersion": "14.13.0"
}
]
}
I'm pretty new to Node.JS so still learning how it fits together. Any suggestions appreciated!
In case we are using selenium-standalone-service for running the test then JAVA-JDK need to be installed. Also below dependency should be available in the package.json
{
"devDependencies": {
"@wdio/selenium-standalone-service": "^6.6.1"
}
}
or
>npm install @wdio/selenium-standalone-service --save-dev
For VScode debugging
As per documentation we will need JavaScript Debugger (Nightly) enabled.
Sample .vscode/launch.json should looks like
{
"name": "run select spec",
"type": "node",
"request": "launch",
"args": ["wdio.conf.js", "--spec", "${file}"],
"cwd": "${workspaceFolder}",
"autoAttachChildProcesses": true,
"program": "${workspaceRoot}/node_modules/@wdio/cli/bin/wdio.js",
"console": "integratedTerminal"
},
Example : launch.json