Home > Back-end >  Unable to Type in "number" input field in Chrome 93 Cypress 8.4.1
Unable to Type in "number" input field in Chrome 93 Cypress 8.4.1

Time:09-27

I am using chrome version 96 and cypress version 8.4.1. Whenever I try to type in an input field with type="number" cypress immediately fails with the error:

InvalidStateError: Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not support selection.

HTML Code: <input type="number" name="phone_lead" id="phone_lead" placeholder=" 92 301 2345678" class="required" autocomplete="off">

-Input Phone number:

cy.get('#phone_lead').click({force:true}).type('16777')

Any solution/suggestion how to resolve this issue?

CodePudding user response:

Error message says what you are doing wrong. You shouldn't use click function. It is not a button and it is not a dropdown. You need just to type in it.

Try without click:

cy.get('#phone_lead').type('16777')

Also try to use data-cy instead of #phone_lead

https://docs.cypress.io/guides/references/best-practices

CodePudding user response:

Try this

cy.get('input[name="phone_lead"]').type('12345678')
  • Related