Reputation: 831
I have problem with typing in one of my fields in automated test. I can't get this field but I don't know why.
This is my code:
cy.get('#reasonRecommendationByAgent')
.type('Zdůvodnění doporučení zprostředkovatele', {force: true})
.should('have.value', 'Zdůvodnění doporučení zprostředkovatele')
And this is the error message:
Is there anyone who has the same problem?
Upvotes: 9
Views: 14025
Reputation: 2547
Try adding a click()
before you type:
cy.get('#reasonRecommendationByAgent')
.click()
.type('Zdůvodnění doporučení zprostředkovatele', {force: true})
.should('have.value', 'Zdůvodnění doporučení zprostředkovatele')
Upvotes: 12
Reputation: 956
We had a similar problem and I was able to fix by adding click and focused. I think, HELP DOCS documents also recommending this.
cy.get('#reasonRecommendationByAgent').click().focused() .type('Zdůvodnění doporučení zprostředkovatele', {force: true}) .should('have.value', 'Zdůvodnění doporučení zprostředkovatele')
Upvotes: 8
Reputation: 5871
According to the error message, it sounds like your code is removing/adding the #reasonRecommendationByAgent
when it's typed into, which is causing Cypress to lose access to it.
Remove any code that might be causing this DOM element to change as it's being typed into and you shouldn't have a problem.
Upvotes: 0