Search code examples
cucumberwebdriver-io

java.net.ConnectException: Connection refused: connect error thrown in the middle of the webdriverio v7 test


I am using webdriverIO v7 and cucumber to test my application.
I have feature file with 10 scenarios.
What happens is that when I run the test then first 4 scenarios are executed seamlessly and on the fifth scenario all of sudden I get the error:

unknown error: java.net.ConnectException: Connection refused: connect
    at Object.getErrorFromResponseBody (C:\my-project\node_modules\webdriver\build\utils.js:189:12)
    at WebDriverRequest._request (C:\my-project\node_modules\webdriver\build\request.js:168:31)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at Browser.runCommandWithHooks (C:\my-project\node_modules\@wdio\sync\build\wrapCommand.js:105:25)
    at Browser.runCommandWithHooks (C:\my-project\node_modules\@wdio\sync\build\wrapCommand.js:100:24)
    at Browser.url (C:\my-project\node_modules\@wdio\sync\build\wrapCommand.js:67:44)
    at MyPage.openImportPage (C:\my-project\src\pages\/myPage.js:32:17)
    at forEach (C:\my-project\src\helpers\/helpers.js:60:21)
    at Array.forEach (<anonymous>)
    at Helpers.deleteWishLists (C:\my-project\src\helpers\/helpers.js:55:51)
    at World.<anonymous> (C:\my-project\src\step_definitions\/config_steps.js:28:13)
    at World.executeSync (C:\my-project\node_modules\@wdio\sync\build\index.js:38:22)
    at World.executeSync (C:\my-project\node_modules\@wdio\sync\build\index.js:52:38)
    at C:\my-project\node_modules\@wdio\sync\build\index.js:69:68

The first step of the fifth scenario is also executed in previous scenarios which succeeded normally.
It doesn't behave consistently - for example, when running for the second time in non headless mode all scenarios passed (all of a sudden).
Running in headless mode, sometimes all scenarios fail with that exception, sometimes only some fail - no rule to notice there.
It is very confusing. I assume it has nothing to do with my tests since sometimes they are all passing, but has to do with my setup or internet connection or webdriverIO framework and its standalone mode ...
Does anybody have clue why is this happening. Who is the trouble maker here?
I don't even know in which direction should I look to in order to investigate this.
Please help.
Thanks!


Solution

  • At the end the issue was with my internet connection.
    Guys from wdio made small patch for it:
    https://github.com/webdriverio/webdriverio/issues/6728