How to type text by cypress cy.type in <ion-input> Input type?

老子叫甜甜 提交于 2019-12-11 19:08:33

问题


< 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!