Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: "Found undefined alias for 'myalias'" when multiple aliases defined for element #4429

Closed
nitzel opened this issue Jun 11, 2019 · 5 comments
Closed

Comments

@nitzel
Copy link

@nitzel nitzel commented Jun 11, 2019

Current behavior:

When using .as('myalias') in a loop the message Found undefined alias for: 'myalias' shows up in the UI but it still works (in the console you can see that the alias resolved to two elements).

The message does not show up when the loop is only executed once.

Desired behavior:

This message should not appear and irritate the developer :)

Steps to reproduce: (app code and test code)

describe('Test', () => {
  it('test', () => {
    cy.visit('http://google.com');
    for (let i = 0; i < 2; i += 1) {
      cy.get('[name="btnK"]').as('search-button');
      cy.get('@search-button');
    }
  });
});

Versions

Cypress 3.3.1
OS Windows 10
Browsers Electron headed

PS:

Am I using aliases incorrectly here or is this just a misguided message from the UI?

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Jun 17, 2019

Oh, yeah, this is a bug. This isn't even concerned with the loop, it seems that when using aliases for elements, if more than 1 is matching, the UI messes up a bit and displays this undefined message.

I believe this was introduced in this PR #2960

Code to reproduce:

it('test', () => {
  cy.visit('http://google.com')
  cy.get('[name="btnK"]').as('search-button')
  cy.get('@search-button')
  cy.get('[name="btnK"]').as('search-button')
  cy.get('@search-button')
})

@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented Jun 26, 2019

The code for this is done in cypress-io/cypress#4556, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-io cypress-io deleted a comment from cypress-bot bot Jun 26, 2019
@jennifer-shehane jennifer-shehane self-assigned this Jun 26, 2019
@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented Jun 27, 2019

Released in 3.3.2.

@aislanmaia
Copy link

@aislanmaia aislanmaia commented Aug 31, 2020

I'm having the same bug

@jennifer-shehane jennifer-shehane removed their assignment Oct 19, 2020
@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Oct 19, 2020

This issue will be closed to further comment as the exact issue here was resolved and tested.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Oct 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants