question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with clear() and type() on text input field (maxlength)

See original GitHub issue

Current behavior:

Cypress is not able to clear() and type() in text input field. The problem is not constant, it appears in my tests only in few scenarios.

Desired behavior:

The clear() and type() actions should always work for input text type field.

Steps to reproduce:

My test looks like follow: I am updating existing element. The update form input text type field:

\<input _ngcontent-trw-171="" class="form-control ng-untouched ng-pristine ng-valid" id="coalTypeDescr" maxlength="25" name="coalTypeDescr" ngcontrol="coalTypeDescr" required="" type="text"\>

My test first needs to clear existing value and add new one:

   cy.get('#coalTypeDescr')
      .clear()
      .type("CoalToEditEdited")

cypressinputfieldproblemwithclear cypressinputfieldproblemwithtype

Console doesn’t show any problem with both functions.

Versions

Cypress 3.0.1, macOS 10.13.5, Chrome

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kathrinkuenzlicommented, Oct 2, 2020

I have got a similar issue with Cypress Version 4.11.0. .clear().type('sometext') does not work. .type('{selectall}sometext') works instead.

Input Field looks like:

<input _ngcontent-aec-c59="" class="mat-input-element mat-form-field-autofill-control cdk-text-field-autofill-monitored ng-pristine ng-valid ng-touched" formcontrolname="link" matinput="" ng-reflect-maxlength="2000" ng-reflect-name="link" ng-reflect-placeholder="z.B. google.ch" maxlength="2000" id="mat-input-1" placeholder="z.B. google.ch" aria-invalid="false" aria-required="false">

1reaction
kapalkatcommented, Jun 29, 2018

@Bkucera Thanks. Looking forward to the patch. In the meantime, I am using a workaround with jQuery; getting the maxlength attribute and increasing it before calling clear() or type() functions on the input element.

Read more comments on GitHub >

github_iconTop Results From Across the Web

maxlength ignored for input type="number" in Chrome
I tried, after entering 4 digits, the textbox, simply gets frozen with no room for any updates, neither delete nor backspace keys works,...
Read more >
HTML attribute: maxlength - MDN Web Docs
The maxlength attribute defines the maximum number of characters (as UTF-16 code units) the user can enter into an <input> or <textarea> ....
Read more >
ion-input: Custom Input Value Type Styling and CSS Properties
The first way is by adding the clearInput property which will show a clear button when the input has a value . The...
Read more >
lightning-input - documentation - Salesforce Developers
A date input field includes a text input to type a date and a date picker to ... The lightning-input component uses the...
Read more >
Text field component - Vuetify
When clearable, you can customize the clear icon with clear-icon. Note that readonly will not remove the clear icon, to prevent readonly inputs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found