What is an alias?
- Assign a value for later use
- We use the '@' symbol for the alias
- It is a named reference or shortcut that represents a specific DOM element, or value, making it easier to reference and re-use
- We can use aliases to store elements and interact with them later
- It can be used to give a name to a series of actions or assertions
- Alias helps to improve code maintainability
What is the method used for keeping aliases?
- as
Provide a sample for usage of alias
- cy.get("#input-field").type("Hello, Cypress").as("inputAlias")
- cy.get("@inputAlias").should("have.value", "Hello, Cypress");
- cy.get('.fixed').invoke('text').as('product')
- cy.get('@product).its('length').eq(8)
No comments:
Post a Comment