I have an input field where I type the value 1000, and when I try to assert the value, the assertion fails: https://i.sstatic.net/4WVhK.png
My code cy.get('#insurance_cover_money').type(1000).should('have.value', '1 000')
HTML: https://i.sstatic.net/0KS7b.png
Thank you!
You can try this.
cy.get('#insurance_cover_money').type('1000').should('have.value', '1000')
If the above is still not working you can do two things:
cy.get('#insurance_cover_money')
.type('1000')
.invoke('val')
.then((val) => {
cy.log(val)
})
cy.get('#insurance_cover_money')
.type('1000')
.should('not.have.value', '0')
.invoke('val')
.then((val) => {
cy.get('#insurance_cover_money').should('have.value', val)
})
You can also try increasing the timeout:
cy.get('#insurance_cover_money', {timeout: 8000})
.type('1000')
.should('have.value', '1000')
cy.get('#insurance_cover_money', {timeout: 8000})
.type('1000')
.should('have.value', '1 000')
In case you want to remove spaces and assert, you can do like this:
cy.get('#insurance_cover_money')
.type('1000')
.invoke('val')
.then((val) => val.replace(/\s/g, ''))
.should('eq', '1000')