I want to check if the text "You must enter a value"(Screenshot attached) is present in the login screen that I have created. This appears when a user touched the input field and then clicked on a different field or area without typing anything. So I tried to test it with cypress, but it says
".type() will not accept an empty string"
Cypress:
it('Should display You must enter a value if user does not type anything', () => {
cy.get('#username').type('')
cy.contains('You must enter a value')
})
I need help in fixing this, thank you.

Just focus and blur indeed:
it('Should display You must enter a value if user does not type anything', () => {
cy.get('#username')
.focus()
.blur()
cy.contains('You must enter a value')
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With