Skip to content

Workers hang after a failed step with some assertions (webdriverio) #4140

Closed
@nikzupancic

Description

@nikzupancic

What are you trying to achieve?

I'm running codecept inside workers but noticed that some assertions will fail and then just hang the whole thread without ever continuing its execution. The problematic assertions are all see ones: see, dontSee, seeElement, dontSeeElement. What I'm expecting is a graceful fail that would then continue with other scenarios within suite (or terminate the connection with test browser/device if this is the only scenario).

What do you get instead?

There are a few lines showing an error. screenshotOnFail captures the image but after that it just hangs, the connection to browser/cloud device is never terminated.

Provide console output if related. Use --verbose mode for more details.

      I dont see element "#app"
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] Error | Error
    [1] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, try to save a screenshot
 › Screenshot has been saved to ./screenshots/Testy_test.failed.png

Provide test source code if related

Using contradictory steps just to show that the test is expected to fail:

Feature('Testing scenario')

Scenario('Testy test', ({I}) => {
    I.amOnPage('https://codecept.io/')
    I.waitForVisible('#app')
    I.dontSeeElement('#app')
})

Details

  • CodeceptJS version: 3.5.6
  • NodeJS Version: 18.7.1
  • Operating System: Ubuntu 20.04.6 LTS (Focal Fossa)
  • webdriverio: 8.15.10
  • Configuration file:
{
    tests: __dirname + 'test.js',
    output: './screenshots'
    bootstrap: () => {},
    teardown: () => {},
    mocha: {},
    plugins: {},
    helpers: {
        WebDriver: {
            restart: false,
            host: 'hub-cloud.browserstack.com',
            port: 4444,
            waitForTimeout: 5000,
            browser: 'Safari',
            platform: 'iOS',
            url: 'https://codecept.io',
            desiredCapabilities: {
                    build: 'testing-run',
                    'browserstack.user': 'X',
                    'browserstack.key': 'X',
                    os_version: '16',
                    device: 'iPhone 14',
                    platform: 'iOS',
            }
        }
    }
}

Note that config given above is using a Browserstack service but I suspect that the results would be the same if running this locally.

My thought was that something breaks in worker-parent communication but I couldn't figure out exactly what goes wrong. When looking at messages that are sent to parent thread I noticed that the last events sent to parent are test.failed and test.finish but nothing after that. Looking at other calls with "graceful failures" I can also see some other events following failed test: suite.after, test.skipped (there are multiple skipped tests in the same scenario), global.failures, global.after.

When it hangs these are the last 2 objects sent from worker to parent:

{"event":"test.failed","workerIndex":1,"data":{"opts":{},"tags":[],"uid":"ryiL1qBCssvxKFySxbhmlw","workerIndex":1,"retries":-1,"title”:””Testy test,”status":"failed","duration":7910,"err":{"message":"","actual":[true],"expected":true},"parent":{"title”:”Testing scenario”}}}
{"event":"test.finish","workerIndex":1,"data":{"opts":{},"tags":[],"uid":"ryiL1qBCssvxKFySxbhmlw","workerIndex":1,"retries":-1,"title”:”Testy test”,duration":7910,"err":null,"parent":{"title”:”Testing scenario”}}}

Other calls (waitForVisible, waitForInvisible etc.) still fail as expected but because the tests are time sensitive I want to verify that elements are visible/invisible at the exact moment which is why waitFor isn't useful for me. Any ideas what's happening? Or at least how to work around this issue?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions