Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kapalkat opened this issue Jun 28, 2018 · 8 comments · Fixed by #2016
Closed

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

kapalkat opened this issue Jun 28, 2018 · 8 comments · Fixed by #2016
Assignees
Milestone

Comments

@kapalkat
Copy link

kapalkat commented Jun 28, 2018

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

@jennifer-shehane jennifer-shehane added type: bug stage: needs investigating Someone from Cypress needs to look at this labels Jun 28, 2018
@kapalkat
Copy link
Author

Next input element with the same problem element type text. I have attached the html code and it's CSS.
Input.zip

@kapalkat
Copy link
Author

I can't type() on the field either as it already has max length filled in, {backspace} or {del} doesn't work so I am not able to edit the form. That's really important problem. Is there any workaround for this?

@kuceb
Copy link
Contributor

kuceb commented Jun 29, 2018

@kapalkat I'm actively working on this right now. Should be in a patch release. This is closely related to other cy.type issues.

@kapalkat
Copy link
Author

kapalkat commented 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.

@kuceb kuceb changed the title Problem with clear() and type() on text input field Problem with clear() and type() on text input field (maxlength) Jun 29, 2018
@kuceb kuceb self-assigned this Jun 29, 2018
@kuceb kuceb added this to the 3.0.3 milestone Jun 29, 2018
@lunheur
Copy link

lunheur commented Jul 13, 2018

@kapalkat Thanks! Workaround works for me. I hadn't even realized the maxlength was the issue. Looking forward to 3.0.3

brian-mann pushed a commit that referenced this issue Jul 23, 2018
this grew to a large PR fixing many cy.type issues.

fix #365
fix #420
fix #586 
fix #593 
fix #596 
fix #610 
fix #651
fix #940
fix #1002 
fix #1108
fix #1171
fix #1209 
fix #1234 
fix #1366
fix #1381 
fix #1684 
fix #1686
fix #1926 
fix #2056
fix #2096 
fix #2110 
fix #2173
fix #2187
@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: needs review The PR code is done & tested, needs review stage: needs investigating Someone from Cypress needs to look at this stage: in progress labels Jul 23, 2018
@kathrinkuenzli
Copy link

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">

@fityanos
Copy link

@jennifer-shehane

+1 for @kathrinkuenzli

It's not working for me as well

HTML
<input placeholder="something" id="eleId" type="something" value="something">

Spec.js
cy.get("#eleId").clear().type("anas@anas.com");

You can notice from the HTML example that I already have some text in the field, however, getting that element and clear it to type anas@anas.com is not working

Actual behavior:
the input field value will be somethinganas@anas.com

"cypress": "5.4.0"

@jennifer-shehane
Copy link
Member

This issue will be closed to further comment as the exact issue here was resolved and tested.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Oct 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants