Skip to content

Prompt: Ability to assert on the order of elements #32831

@jennifer-shehane

Description

@jennifer-shehane

What would you like?

The selector's or assertions of the prompt should be updated so that the intent of the test is achieved.

cy.prompt([
  'The first product should be "Backpack"',
  'The last product should be "Hat"',
])

Sometimes this results in something like:

cy.get('#backpack').should('have.text', 'Backpack')
cy.get('#hat').should('have.text', 'Hat')

But the intent of the test really should result in something like below:

cy.get('#products').first().should('have.text', 'Backpack')
// or
cy.get('#products').eq(0).should('have.text', 'Backpack')
// or
cy.get('#products:first').should('have.text', 'Backpack')
// or
cy.get('#products:nth-child(0)').should('have.text', 'Backpack')

Why is this needed?

No response

Other

No response

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