Problem with clear() and type() on text input field (maxlength)
See original GitHub issueCurrent 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")
Console doesn’t show any problem with both functions.
Versions
Cypress 3.0.1, macOS 10.13.5, Chrome
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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">
@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.