how can I test the Textarea text which is disappearing after you start to write something?
after I write something nothing changes on showed dom.
I want to test that Enter a comment.
texts disappearing.
Thank you for advices...
CodePudding user response:
Expanding on @Prophet's answer:
I would test the placeholder and the value of the input, in that order.
cy.get('your textarea selector')
.should('have.attr','placeholder','Enter a comment.')
.type('stackoverflow')
.should('have.value','stackoverflow')
Edit: Checking if the textarea is empty before typing (more robust test). Another option could be doing a .clear before the .type
cy.get('your textarea selector')
.should('have.attr','placeholder','Enter a comment.')
.should('have.value','')
.type('stackoverflow')
.should('have.value','stackoverflow')
CodePudding user response:
You can get the value
attribute of that textarea
element.
Something like the following:
theValue = textarea.getAttribute('value')