Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value not be empty workaround in cypress [closed]

Tags:

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

like image 716
user1868774 Avatar asked Sep 07 '25 07:09

user1868774


1 Answers

I assume you want to check whether your value is empty or not. You can do something like this:

cy.get('car').find('input').invoke('val').should('not.be.empty')
like image 66
Alapan Das Avatar answered Sep 11 '25 00:09

Alapan Das