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
cy.type() adhere to maxlength on text input #928
Comments
Can confirm - is a bug in v1.0.3. On typing over maxlength, the input displays more than maxlength and the assertions fail, returning the value beyond the allowed maxlength. HTML <input type="text" class="wait-input1" maxlength="5"> Test code it('Type over maxlength', function(){
cy.visit('http://localhost:8080/commands/waiting')
cy.get('.wait-input1').type('123456789')
.should('have.value', '12345')
.and('not.have.value', '123456789') For solution, PRs welcome |
I'd love to submit a PR here. This is the first time I have contributed to a project on github (outside of my own). I will carefully read the contributing.md doc and get started. Please let me know if there's anything outside of that doc that I should know. Thanks! |
Awesome @JosiahRooney, feel free to open a WIP PR if you get stuck or have questions at all. 👍 |
I'm wondering if this would suffice (adding to line 115 of packages/driver/src/cy/commands/actions/type.coffee): if options.$el.attr("maxlength") and chars.length > options.$el.attr("maxlength")
chars = chars.slice(0, options.$el.attr("maxlength")) |
I made a WIP PR here: #930 @jennifer-shehane |
@jennifer-shehane I think this is all finished up. Do I close the issue now or do you guys do that? Thanks |
Fixed by #930 |
Released in |
I'm very new to all this, but I just wanted to ask if someone could verify whether the fix that was included in 1.1.1 considers special character sequences like {selectall} and {backspace} when respecting the maxlength attribute. |
That's a good point. It likely does not. A quick test would confirm this. |
I upgraded to 1.1.1 yesterday but had to roll back to 1.1.0 because several of my tests that used textboxes with a maxlength attribute started failing. The cy.clear() command was also affected for obvious reasons. |
Is this a Feature or Bug?
Feature
Current behavior:
cy.type ignores maxlength attribute on an input element.
Desired behavior:
cy.type() should not ignore maxlength attribute on an input. After .type() reaches the maxlength, it should ignore the rest of the input string.
How to reproduce:
Use cy.type() on a text input with a maxlength attribute, passing a string to .type() that is longer than the maxlength.
The text was updated successfully, but these errors were encountered: