'Value not be empty workaround in cypress
Please cypress is giving me undefined error when I want to check that the input is not empty like this:
cy.get('car').find('input').should('not.be.empty');
When I put a value into input like bmw and use a code like this, all is fine
cy.get('car').find('input').should('have.value', 'bmw');
So it finds the input and can read the value, but why the not.be.empty is not working? Is there some workaround to that? I do not want to specific the value of the field, could be random. Thx
Solution 1:[1]
An empty input will have a string value of "".
cy.get('car').find('input').should('not.have.value', '');
The assertion .should('not.be.empty') applies to the text content e.g <div>MyText</div>.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
