Cypress: cy.type(force: true) doesn't type characters for readonly inputs

Created on 8 Jan 2020  路  3Comments  路  Source: cypress-io/cypress

Hello i have found one bug in newest version cypress (3.8.1). In cypress 3.4.1 can type readonly input with option {force: true} but in new version stop working.

It doesn't throw exception but don't fill the input.

pkdriver cy.type 鈱笍 regression v3.5.0

Most helpful comment

This is a regression in Cypress 3.5.0

index.html

<html>
<body>
<input readonly />
</body>
</html>

spec.js

it('types in readonly', () => {
  cy.visit("index.html")
  cy.get('input').type('foo', {force: true})
    .should('have.value', 'foo')
})

3.4.1

Screen Shot 2020-01-08 at 2 33 19 PM

3.5.0

Screen Shot 2020-01-08 at 2 32 03 PM

Code

It seems the check for whether we should type does properly run if force !== true here, so the error does not throw if it is readonly with force: true. https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/actionability.js#L328:L328

The problem though is that the actual typing is not occurring on the input.

We did not have a test for this although we should have here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/test/cypress/integration/commands/actions/type_spec.js#L224:L224

Workaround

Downgrade to Cypress 3.4.1.

All 3 comments

This is a regression in Cypress 3.5.0

index.html

<html>
<body>
<input readonly />
</body>
</html>

spec.js

it('types in readonly', () => {
  cy.visit("index.html")
  cy.get('input').type('foo', {force: true})
    .should('have.value', 'foo')
})

3.4.1

Screen Shot 2020-01-08 at 2 33 19 PM

3.5.0

Screen Shot 2020-01-08 at 2 32 03 PM

Code

It seems the check for whether we should type does properly run if force !== true here, so the error does not throw if it is readonly with force: true. https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/actionability.js#L328:L328

The problem though is that the actual typing is not occurring on the input.

We did not have a test for this although we should have here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/test/cypress/integration/commands/actions/type_spec.js#L224:L224

Workaround

Downgrade to Cypress 3.4.1.

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

Released in 3.8.3.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v3.8.3, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weskor picture weskor  路  3Comments

stormherz picture stormherz  路  3Comments

carloscheddar picture carloscheddar  路  3Comments

egucciar picture egucciar  路  3Comments

verheyenkoen picture verheyenkoen  路  3Comments