WebdriverIO SevereServiceErrror not stopping the test run - webdriver-io

I have setup a custom wdio service (as per the documentation) which is used to create a build for the Angles automation dashboard.
As part of this service I want to use the SevereServiceError when it is unable to create the build and stop the run. However in my example test it throws the error and simply continues the test run. See logs here:
2022-03-05T07:28:36.936Z INFO #wdio/cli:launcher: Run onPrepare hook
2022-03-05T07:28:36.936Z INFO chromedriver: Start Chromedriver (/git/angles/webdriverio-example/node_modules/chromedriver/lib/chromedriver/chromedriver) with args --port=9515 --url-base=/
2022-03-05T07:28:36.982Z ERROR #wdio/cli:utils: A service failed in the 'onPrepare' hook
SevereServiceError: Unable to create a build due to connect ECONNREFUSED 127.0.0.1:3000.
at /Users/sergios/Documents/git/angles/webdriverio-example/node_modules/angles-wdio-reporter/src/integrations/wdio/AnglesWDIOService.ts:57:15
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async /Users/sergios/Documents/git/angles/webdriverio-example/node_modules/#wdio/cli/build/utils.js:28:17
at async Promise.all (index 1)
at async Launcher.run (/Users/sergios/Documents/git/angles/webdriverio-example/node_modules/#wdio/cli/build/launcher.js:86:13)
Continue...
2022-03-05T07:28:36.985Z INFO chromedriver: Starting ChromeDriver 98.0.4758.102 (273bf7ac8c909cde36982d27f66f3c70846a3718-refs/branch-heads/4758#{#1151}) on port 9515
2022-03-05T07:28:36.987Z INFO chromedriver: Only local connections are allowed.
You can run the example yourself by cloning the example repo and running npm run test.
NOTE: This should fail because it's looking for a local instance of the Angles dashboard.
Any ideas why the SevereServiceError isn't stopping the test run?

By updating wdio dependencies and ts-node and typescript to current versions this issue has been resolved. The test run now stops when the SeverServiceError is thrown.

Related

Webdriver IO face with spec node found error above Node.js version 14

Description:
I can't trigger webdriver io test feature under node.js 16.
I have tried 14.20.0 worked for me, but face with element locating issue.
With node version below, all same issue happened:
v16.16.0
v18.12.1
v18.13.0
v19.4.0
And most unbelievable is that, same code code with same node and npm version on windows machine, all works good and pass.
I'm very confused about if the webdriver io is not supported on Mac or not.
Env:
1.Mac OS 12.6.2 (21G320)
2.Node version v16.16.0
3.Npm version 9.4.0
Error Log:
automationtests#1.0.0 Test
npx wdio run wdio.conf.ts
Execution of 0 workers started at 2023-02-07T05:43:36.724Z
Starting Cucumber Test
2023-02-07T05:43:38.278Z ERROR #wdio/cli:launcher: No specs found to run, exiting with failure
2023-02-07T05:43:38.332Z ERROR #wdio/cli:utils: Error in onCompleteHook: Error: There were issues reading JSON-files from '.tmp/json'.
at collectJSONS (/Users/jjiang310/IdeaProjects/fc-ui-test-automation/node_modules/multiple-cucumber-html-reporter/lib/collect-jsons.js:27:15)
at Object.generateReport [as generate] (/Users/jjiang310/IdeaProjects/fc-ui-test-automation/node_modules/multiple-cucumber-html-reporter/lib/generate-report.js:79:23)
at Object.onComplete (/Users/jjiang310/IdeaProjects/fc-ui-test-automation/wdio.conf.ts:407:38)
at /Users/jjiang310/IdeaProjects/fc-ui-test-automation/node_modules/#wdio/cli/build/utils.js:99:19
at Array.map ()
at runOnCompleteHook (/Users/jjiang310/IdeaProjects/fc-ui-test-automation/node_modules/#wdio/cli/build/utils.js:97:39)
at Launcher.run (/Users/jjiang310/IdeaProjects/fc-ui-test-automation/node_modules/#wdio/cli/build/launcher.js:96:75)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Spec Files: 0 passed, 0 total (0% completed) in 00:00:01
I have tried different node version, and test the same code with same node and npm version run on Windows machine can all pass which can make sure there is no code level problem to make the test case failed.
I expected the code can run and pass on Mac machine same as the windows.

Running against Edge on selenium-standable server

I am trying to run Edge in selenim-standalone server on my Mac.
I’ve followed the CLI command to install but when I try to with wdio project I get the following error:
ERROR webdriver: org.openqa.selenium.SessionNotCreatedException: Unable to create new service: EdgeDriverService
Started my server using this command:
selenium-standalone start --drivers.chrome.version=98.0.4758.80 --drivers.chrome.baseURL=https://chromedriver.storage.googleapis.com
I have not had much luck finding another person having the same issue.
Server is running with node 14
Wdio project is running with node 16
any thoughts on what it might be?
Issue resolved.
I ended up running the install command in node v16 and that worked. I did have to delete selenium-server jar file the first time because it was corrupt. Though I re-ran the install command again it worked.

Protractor installed in offline mode - error for webdriver-manager start - what am I doing wrong

I need to install and use Protractor / Selenium on the machine without Internet access.
To do that, I've tried to download all needed files and copy them to the destination machine.
On my machine (with Internet access)
I installed Protractor and Selenium webdriver with the following command:
npm install -g protractor
webdriver-manager update
On destination machine (without Internet access)
I copied all files from the location returned by npm config get prefix to the computer without Internet access.
Then I executed following command on the machine without Internet access:
npm --cache-min 9999999 install -g protractor
which seems to succeed.
However, when I try to execute webdriver-manager start command, I receive following error message:
events.js:183
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND chromedriver.storage.googleapis.com
chromedriver.storage.googleapis.com:443
at errnoException (dns.js:50:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
I receive the same error when executing webdriver-manager update (as in this case: webdriver-manager start: Error: connect ETIMEDOUT)
Question
What am I doing wrong? How should I properly setup Protractor and webdriver on the machine without Internet access?
Because webdriver-manager start will look up the latest version number of selenium-server.jar and webdriver binaries through internet no matter they are already exists on local.
But webdriver-manager not supply cmd option to disable the looking up.
The quick way is to run the java cmd behind webdriver-manager start directly to skip the looking up.
java
-Dwebdriver.chrome.driver=C:\Tools\npm-global\node_modules\webdriver-manager\selenium\chromedriver_2.38.exe
-Dwebdriver.gecko.driver=C:\Tools\npm-global\node_modules\webdriver-manager\selenium\geckodriver-v0.20.1.exe
-jar C:\Tools\npm-global\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.11.0.jar
-port 4444
The complex way is to change webdriver-manager code or setup a mirror on local and use cmd option: --alternate_cdn and point it to your local mirror url. ( I didn't verify this can work, get it after read some source code)

webdriver manager not working behind proxy

I need to use webdriver-manager to execute:
webdriver-manager update --proxy=https://proxy.company.com:8080
But get
webdriver-manager: using local installed version 12.0.6
events.js:160
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at exports._errnoException (util.js:1020:11)
at TLSWrap.onread (net.js:568:26)
i.e. the proxy command still does not seem to work for 12.0.6 for me.
What worked for me was adding --ignore_ssl in addition to --proxy
webdriver-manager update --proxy=http://someproxy:8080 --ignore_ssl
As question title sounds if-you want to use webDriver manager being behind proxy then use it like below in your browser instantiation class-
WebDriverManager.chromedriver().proxy("YourProxyServerUrl:YourPort").setup();
driver = new ChromeDriver(chromeOptions-if you have);
And if you looking for:updating the selenium webdriver using the "webdriver-manager
Refer below thread -
selenium webdriver manager update - npm

yeoman generated app crashes on running grunt command

I am getting the following error when I run the grunt command after generating the app using Yeoman generator:
Loading "grunt-karma.js" tasks...ERROR
>> TypeError: Cannot read property 'prototype' of undefined
>> Local Npm module "grunt-node-inspector" not found. Is it installed?
Running "env:dev" (env) task
Running "sass:dist" (sass) task
Running "less:dist" (less) task
Running "jshint:all" (jshint) task
>> 86 files lint free.
Running "csslint:all" (csslint) task
>> 2 files lint free.
Running "mkdir:upload" task
Running "copy:localConfig" (copy) task
Copied 1 file
Running "concurrent:default" (concurrent) task
Loading "grunt-karma.js" tasks...ERROR
>> TypeError: Cannot read property 'prototype' of undefined
Loading "grunt-karma.js" tasks...ERROR
>> TypeError: Cannot read property 'prototype' of undefined
>> Local Npm module "grunt-node-inspector" not found. Is it installed?
>> Local Npm module "grunt-node-inspector" not found. Is it installed?
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: server.js config/**/*.js
modules/*/server/**/*.js
[nodemon] starting `node --debug server.js`
(node:16253) [DEP0062] DeprecationWarning: `node --debug` and `node --debug-brk` are invalid. Please use `node --inspect` or `node --inspect-brk` instead.
[nodemon] app crashed - waiting for file changes before starting...
I found a similar question(Yeoman grunt could not connect to MongoDB) but I was not able to find the solution to my problem there.
Is that an old version of MEAN.js? I believe grunt was replaced by gulp and also an issue regarding node-inspector was fixed by this pull request.
You should check which version you're using and make the necessary changes.