Clear Input Element Flake

Описание к видео Clear Input Element Flake

This video shows how the test can avoid a race condition trying to clear / type into an input field before the application sets the initial value on load. Find the full recipe at https://glebbahmutov.com/cypress-exam... and below is the solution code
// wait for the app to finish setting the initial value
// which is different from the static attribute
cy.get('#answer')
.should('have.attr', 'value')
.then(function (staticValue) {
cy.get('#answer')
.invoke('val')
.should('not.equal', staticValue)
})
// now we can clear the input field safely
cy.get('#answer').clear().type(42).should('have.value', 42)

Комментарии

Информация по комментариям в разработке