Cypress: Missing letters when using type

Created on 25 Mar 2019  路  17Comments  路  Source: cypress-io/cypress

Current behavior:

I just upgraded to Cypress 3.2.0 and noticed this strange behavior with type

missingFirstLetter

For some reason the first letter gets cut out, this test used to run fine in 3.1.5.

Desired behavior:

That the typed text does not get cut short

Steps to reproduce: (app code and test code)

The test

  it('Successful login', () => {
    cy.visit('/')
    cy.get('head title')
    .should('contain', 'Log in')
    cy.get('#email')
      .type('Admin{enter}', {force: true, delay: 700})
    cy.get('#password')
      .type('superSafePassword{enter}')
    cy.get('.primary').click()
    cy.get('#title')
      .should('contain', 'Dashboard')
  });
});

The form

<div class='right'>
  <p class='greeting'>Log in to your account</p>
  <ListErrors {errors}/>

  <form on:submit='submit(event)' autocomplete='off'>
    <fieldset class='login'>
      <img alt='user' src='img/user.svg' class='login-icon' />
      <input type='text' placeholder='Email' id='email' autocomplete='off' bind:value=email>
    </fieldset>

    <fieldset class='login'>
      <img alt='password' src='img/password.svg' class='login-icon' />
      <input type='password' placeholder='Password' id='password' autocomplete='new-password' bind:value=password>
    </fieldset>
    <Button kind='primary block' type='submit' disabled='{!email || !password}'>Log in</Button>
  </form>
</div>

Versions

Windows 10
Cypress 3.2.0
Chrome 73.0.3683.86 (Official Build) (64-bit)

Most helpful comment

I had an issue with password not matching. Here's what i tried

cy.get("#password").find("[type='password']").wait(500).clear().type('password',{delay: 700}) cy.get("#repeat-password").find("[type='password']").type('password')
Does cy.get("#password").wait(500).type('password') work fine?

All 17 comments

I added cy.wait(500); in the beginning of the test and now it passes. Seems like Cy runs just a bit too fast :) What is the recommended action when dealing with issues like this? I dont really want to add wait to all of my test cases

@Mattinn this is a common question and a problem. See my two blog posts about it

Thanks Gleb, these posts explain the problem very well 馃憤

Screenshot 2020-06-10 at 1 23 10 PM
I'm still having same issue.
I try to

type('AID')

type('First name')

type('Last name')

etc and the first letters are skipping

I found this issue when Googling for why my field is missing the first few characters of my type.

cy.get('#customer-postcode').type('W1A 1AA');
cy.get('#customer-postcode').should('have.value', 'W1A 1AA');

I expected to see W1A 1AA but usually all I get is A 1AA or a variation thereof. I have had to add a check for the value to force the test to fail when Cypress cannot correctly fill the field.

I am using Cypress 4.10.0

same here

This is not flaky cypress 4.11.0 has the same issue

Some of you may be experiencing this issue: https://github.com/cypress-io/cypress/issues/5480

This specific issue that the original poster was experiencing has been closed as fixed however.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

I solved my issue by adding cy.wait(500) before trying to type. Presumably a vagary of my interface.

I solved my issue by adding cy.wait(500) before trying to type. Presumably a vagary of my interface.

I don't think it is a good idea to keep hardcoded wait before every type.

I solved my issue by adding cy.wait(500) before trying to type. Presumably a vagary of my interface.

I don't think it is a good idea to keep hardcoded wait before every type.

so what the alternative ?

By using a work-around like cy.wait() some time the above issue disappears, but the original issue remains the same.

By using a work-around like cy.wait() some time the above issue disappears, but the original issue remains the same.

Yeah. Exactly.

Here is another workaround which worked for me.
I have used tab along with focus and clear to move between input fields.
javascript: cy.get('div[class*=first_name] input').type('Kangs').should('have.value', 'Kangs').tab() cy.get('div[class*=last_name] input').focus().clear().type('Passoubady').should('have.value', 'Passoubady').tab()
look for cypress-plugin-tab here

I had an issue with password not matching. Here's what i tried and this worked for me.

cy.get("#password").find("[type='password']").wait(500).clear().type('password',{delay: 700}) cy.get("#repeat-password").find("[type='password']").type('password')

I had an issue with password not matching. Here's what i tried

cy.get("#password").find("[type='password']").wait(500).clear().type('password',{delay: 700}) cy.get("#repeat-password").find("[type='password']").type('password')
Does cy.get("#password").wait(500).type('password') work fine?

Hey, I see people commenting on this issue, despite it being closed. If you have a reproducible example you can share with us (so we can run it ourselves to see the problem), please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stormherz picture stormherz  路  3Comments

igorpavlov picture igorpavlov  路  3Comments

egucciar picture egucciar  路  3Comments

rbung picture rbung  路  3Comments

brian-mann picture brian-mann  路  3Comments