Asserting that an input element contains a specific value in Cypress

I am trying to assert the following where propSizeSel is the CSS selector to my numerical input element:

    .should('contain', 100);

Unfortunately, this assertion fails in the following manner despite the input element accepting the value of 100.

enter image description here

As you can see the input element has accepted the value 100 as expected:

enter image description here

Why is it that I can't seem to make this simple assertion?

1 answer

  • answered 2018-11-08 11:05 soccerway

    Please try with 100 in single quotes and in the assert, please use should('have.value', '100') instead of contain;

    cy.get('propSizeSel').clear().type('100').should('have.value', '100');

    or try asserting using a promise

          const myVal = val;