Skip to content

Cypress is referencing to the wrong aliased element #17470

@wlsf82

Description

@wlsf82

Current behavior

I have a test that has three aliases for three different elements. They are:

cy.contains('button', 'Start')
  .as('startBtn')

cy.get('input[type="text"]')
  .as('textField')

cy.contains('button', 'Reset')
  .as('resetBtn')

As you can see, every alias refers to a different element.

The last assertion of my test is:

cy.get('@resetBtn')
  .should('not.exist')

And this exact step fails with the following error:

AssertionError: Timed out retrying after 4000ms: Expected to find element: `input[type="text"]`, but never found it.

Desired behavior

Cypress should refer to the correct element through its alias, and the tests should pass.

Test code to reproduce

Here's a draft PR that changes a sample app and updates its test, which fails with a failure that seems to be a Cypress issue: wlsf82/live-tat-code-cov#3.
And here's the failing test result from GitHub Actions https://github.com/wlsf82/live-tat-code-cov/pull/3/checks?check_run_id=3148179864.

Cypress Version

I tried on versions 8.0.0 and 7.7.0, and the issue happens on both of them.

Other

I'm using a macOS Big Sur Version 11.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions