How to get the text input field value to a 'const' variable in Cypress, so that I can log that variable using cy.log(). The below code doesn't log anything, can someone familiar with Cypress.io please advise
cy.get('input[name="email"]').then(($text)=>{
const txt = $text.text()
cy.log(txt)
})
Using invoke('val')
instead of invoke('text')
worked for my case.
Reminder of the html tag
<input type="text" class="form-control" name="email">
Cypress code
cy.get('input[name="email"]')
.invoke('val')
.then(sometext => cy.log(sometext));