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

Comments

@abaybabaydabudidabuday
Copy link

@abaybabaydabudidabuday 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

This comment has been minimized.

Copy link

@aelmekeev aelmekeev commented Dec 18, 2019

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

This comment has been minimized.

Copy link

@Narretz 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

This comment has been minimized.

Copy link
Author

@abaybabaydabudidabuday abaybabaydabudidabuday commented Dec 19, 2019

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

This comment has been minimized.

Copy link
Member

@jennifer-shehane 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

This comment has been minimized.

Copy link
Member

@jennifer-shehane 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
@Bkucera Bkucera mentioned this issue Dec 23, 2019
2 of 2 tasks complete
@cypress-bot

This comment has been minimized.

Copy link

@cypress-bot 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

This comment has been minimized.

Copy link

@cypress-bot 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.
Projects
None yet
5 participants
You can’t perform that action at this time.