.type() will not accept an empty string
See original GitHub issueCurrent behavior:
CypressError: cy.type() cannot accept an empty String. You need to actually type something.
Desired behavior:
An empty string is a valid an often necessary test on an input field. The type method should support this.
Steps to reproduce: (app code and test code)
cy.get('input element').type('')
Versions
Cypress: 3.1.5 MacOs Mojave 10.14.3 Chrome 72
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (2 by maintainers)
Top Results From Across the Web
type() will not accept an empty string cypress - Stack Overflow
Just focus and blur indeed: it('Should display You must enter a value if user does not type anything', () => { cy.get('#username') .focus()...
Read more >21.2 Validating Null and Empty Strings
An empty string is a string instance of zero length, whereas a null string has no value at all. An empty string is...
Read more >DFDL empty strings causing a CTDU4132E error and APARs ...
There is currently no solution for cases where the element is a blank string and the data type is non-numeric. Finding an applicable...
Read more >Handle empty strings when migrating from Oracle to PostgreSQL
During code migration from your Oracle to PostgreSQL database, adding NULLIF is required only for character varying data types. This is not ......
Read more >String field type doesn't consider empty string as empty value
but $entity->validate() would accept empty string as a value, because the the field has an item (with value empty string) ?
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 Free
Top 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
Can we re-open this? I’m trying to write dynamic tests that cleanup after themselves. Take the value of input A and store it for later. Type something, click save and assert on reload that it’s there.
Now in the cleanup phase I want to write back whatever value was there before. This is where cy.type is breaking my tests if the original value was an empty string.
I have to add an if statement that basically checks to see if the original value was an empty string, and if it was, then don’t call cy.type. This isn’t ideal, cy.type feels like any string value should be a valid argument - even an empty string.
If you want to set the value of an input as an empty string, you can do this programatically. A person cannot type an empty string, so this will not be supported in
.type().To do this programmatically: