Search code examples
javascriptseleniumautomationcypresstextarea

Textarea text dissapear test with Cypress


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.

enter image description here

I want to test that Enter a comment. texts disappearing. enter image description here

Thank you for advices...


Solution

  • 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')