问题
< ion-input data-cy="email" type="email" class="border" placeholder="EMAIL">
If I do var typedText = 'test@email.com'
cy.get('[data-cy=email]')
.type(typedText,{ force: true })
.should('have.value',typedText)
the test run shows error like
CypressError: cy.type() failed because it requires a valid typeable element.
回答1:
var typedText = 'test@email.com'
cy.get('[data-cy=type-email]>[data-cy=type-email]')
.type(typedText)
.should('have.value',typedText)
OR
var typedText = 'test@email.com'
cy.get('[data-cy=password]').children()
.type(typedText)
.should('have.value',typedText)
This worked for ionic.
回答2:
The cypress documentation for the type() method states that in order to use it in conjunction with a non-input or non-textarea you have to apply the tabindex attribute to the element you wish to type into.
They do not explain why that is and I have not worked with cypress myself. I hope this works for you.
来源:https://stackoverflow.com/questions/53061718/how-to-type-text-by-cypress-cy-type-in-ion-input-input-type