cy.get('#name').type('Mani')
var Name =cy.get('#name').text
cy.log(Name)
cy.log(Name+ 'Hello, this practice page and share your knowledge')
I stored the name in the ‘Name’ variable and display it properly in cy.log(Name). But when I am trying to concatenate with variable(Name) it’s getting unefined.
I want to be display like "John Hello…."
2
Answers
Try this
Please read the documentation at Variables and Aliases.
The standard way to handle variables in Cypress tests is via an alias. The syntax you need is
cy.get(something).as('myVar')
In your example