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.

{enter} on input type=number leads to invalid input (3.8.0 regression)

See original GitHub issue

Current behavior:

when you type a number in an number input and then type enter, the input becomes empty and the console logs an error:

cypress_runner.js:107262 The specified value "12\n" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)?

You can see that the {enter} adds \n to the input value.

Desired behavior:

It should set the value without \n

Steps to reproduce: (app code and test code)

html:

<input type="number" id="input" />

spec code:

cy.get('#input')
  .type('2')
  .type('{enter}')

Versions

Cypress 3.8.0 edit: Chrome 79 with cypress run

Possibly related to https://github.com/cypress-io/cypress/pull/5854

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Dec 20, 2019

@Narretz Right, sorry. It’s helpful to provide the incorrect failing test case. So, the assertion below incorrectly fails.

I do see the message in the console. I misread and thought that was an error throwing in the Test Runner directly.

<!DOCTYPE html>
<html>
<body>
  <input type="number" id="input" />
</body>
</html>
it('types', function () {
  cy.visit('index.html')
  cy.get('#input')
  // doing .type('2{enter}`) causes same error
    .type('2')
    .type('{enter}') 
    .should('have.value', '2')
})

3.7.0

Screen Shot 2019-12-20 at 1 26 45 PM

3.8.0

Screen Shot 2019-12-20 at 1 12 07 PM

2 console table

Screen Shot 2019-12-20 at 1 29 40 PM

{enter} console table

Screen Shot 2019-12-20 at 1 29 01 PM

0reactions
cypress-bot[bot]commented, Dec 26, 2019

Released in 3.8.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why the number input is the worst input - Stack Overflow Blog
Either way when the number is invalid you can't get the actual value that appears on screen in the <input type="number"> field:
Read more >
In Chrome why can the invalid input `1-1` be typed in an ...
But both of these values are invalid: input.value is the empty string. What is the logic behind this behavior? Example below for you...
Read more >
Changelog — Python 3.11.1 documentation
SSLSession objects is no longer allowed as it lead to misconfigured ... Formerly, it did not convert the input type when for sequences...
Read more >
Changelog - Cypress Documentation
Fixed an issue where the incorrect Cypress version could be shown in the ... We fixed a regression in 3.8.0 where using .type()...
Read more >
PySimpleGUI
There are no pesky classes you are required to write, no callback functions to worry about. None of that is required to show...
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