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

.type() does not type chars in number input beyond special chars (like ,) #5997

Closed
abaybabaydabudidabuday opened this issue Dec 18, 2019 · 7 comments · Fixed by #6033
Closed
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cy.type ⌨️ type: regression A bug that didn't appear until a specific Cy version release v3.8.0 🐛 Issue present since 3.8.0

Comments

@abaybabaydabudidabuday
Copy link

abaybabaydabudidabuday commented Dec 18, 2019

Current behavior:

Pre-conditions - in my text form "," sign not allowed to input

Input inside type() func:

1,99

Output:

1

Desired behavior:

199

It worked in previous version of cypress correctly and problem I met in 3.8.0

Steps to reproduce: (app code and test code)

Just try to type from tests some signs that couldn't be written.

Versions

Cypress 3.8.0
OS: Mac Mojave
Browser: Chrome

@abaybabaydabudidabuday abaybabaydabudidabuday changed the title 3.8.0 type() edge cases doesn;t work for new version. 3.8.0 type() func doesn;t work for edge cases in new version. Dec 18, 2019
@aelmekeev
Copy link
Contributor

What is the type of your input? We've also noticed some difference in recent versions and tracked it down to these regexp:

const numberRe = /^-?(0|[1-9]\d*)(\.\d+)?(e-?(0|[1-9]\d*))?$/i

To be honest I don't think that automation framework should do this at all.

@Narretz
Copy link
Contributor

Narretz commented Dec 18, 2019

This is only for number inputs, and Cypress has to do this because they replicate certain browser / html functionality, unlike Selenium.
But I agree, something went really quite wrong with the number input in 3.8.0.

@abaybabaydabudidabuday
Copy link
Author

What is the type of your input? We've also noticed some difference in recent versions and tracked it down to these regexp:

I'm using them as string obj. Should I prefer to use them as a number type or it doesn't matter?

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Dec 19, 2019

@abaybabaydabudidabuday Can you paste in the html of the input element? We want to know the type attribute. Should look something like:

<input type="???" />

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Dec 19, 2019

I verified this behavior in 3.8.0.

When typing manually, I can type 1 , 0 0 0 where the , does not display in the input, but the entire 1000 is set as the value.

index.html

<!DOCTYPE html>
<html>
<body>
  <input type="number"/>
</body>
</html>
it('Type in number', () => {
  cy.visit('index.html')
  cy.get('input').type('1,000')
})

3.7.0

Screen Shot 2019-12-19 at 2 57 47 PM

Events table when clicking on 'type' command

Screen Shot 2019-12-19 at 2 59 53 PM

3.8.0

You can see the test run where it only has 1 in the value.

Screen Shot 2019-12-19 at 2 56 30 PM

Events table when clicking on 'type' command. Seems like the input event is never firing for the , + 0 characters.

Screen Shot 2019-12-19 at 2 53 24 PM

Workaround

Roll back to 3.7.0 in the meantime.

@jennifer-shehane jennifer-shehane changed the title 3.8.0 type() func doesn;t work for edge cases in new version. .type() does not type chars in number input beyond special chars (like ,) Dec 19, 2019
@jennifer-shehane jennifer-shehane added v3.8.0 🐛 Issue present since 3.8.0 type: regression A bug that didn't appear until a specific Cy version release labels Dec 19, 2019
@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Dec 19, 2019
@jennifer-shehane jennifer-shehane added pkg/driver This is due to an issue in the packages/driver directory topic: cy.type ⌨️ labels Dec 19, 2019
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Dec 23, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 23, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 23, 2019

The code for this is done in cypress-io/cypress#6033, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 26, 2019

Released in 3.8.1.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory topic: cy.type ⌨️ type: regression A bug that didn't appear until a specific Cy version release v3.8.0 🐛 Issue present since 3.8.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants