cypress: Missing letters when using type

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)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 61 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I’m hitting this bug for the 4th time in 12 months of various fresh installations.

  1. the WORKAROUND (without using an arbitrary wait()) that I use is simply to duplicate the very first input type() command. Something like the following:
    cy.get("input[name=email]").type("x"); // dummy input to "warm up" Cypress
    cy.get("input[name=email]").clear().type(email);
    cy.get("input[name=password]").type(password);
    cy.get("button[type=submit]").click();
  1. This is has been so consistent it’s hard to believe that no maintainers can reproduce it; but here’s some markup (pug) to run it against that hopefully can help debug (@jennifer-shehane 🙏🏾 ). It’s essentially just an input for email and password with a button to submit the form
form
    div
      label(for="email") Email
      input(
        name="email",
        placeholder="Email",
        type="email",
        autocomplete="username"
      )
    div
      label(for="password") Password
      input(
        name="password",
        placeholder="Password",
        type="password",
        autocomplete="current-password"
      )
    button(type="submit") Log in

Really hope this can help because persistent bugs like this for what should be simple example really trip me up when trying to evangelise about the joys & ease of testing with awesome tools like Cypress.

Hope this can help any other googlers or at least help me converge towards this workaround much quicker next time 😅

The issue is still exists

This issue needs to be reopened as it still exists

@sra1rdy If you can provide a reproducible example that we can run to see the issue, we’d be happy to reopen.

Facing same issue.

Still exists in v.7.2.0 as well, but a workaround for this, you can use the following.

const httpSettingName = cy.get('[data-testid=cy-http-setting-name]'); // or you can select how you would like to
httpSettingName.wait(0).focus().clear().type('your_value_comes_here');

Waiting 0 ms means you do not slow down your tests but give Cypress enough time to “warm-up”.

Interesting solution with 0 ms. Ill try that out

The issue still exists v.7.3.0 It’s only happening on one input, i couldn’t find the reason but adding .wait(500) solve the problem for me cy.get('input[name="customer-search-string"]').first().wait(500).clear().type(TEST.CUSTOMER.PHONE);

@akwasin If you have a reproducible example that we can run completely and see the error, you can email it so support@cypress.io

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

Or the hell with cypress .type() and use .text() which never failed me. If in need to type {enter} {esc} etc then .text('sometext').type('{enter}')

Cypress.Commands.add('text', {prevSubject: true}, (subject, text) => {
    subject.val(text)
    return cy.wrap(subject)
})

Don’t you think that is the issue with you application?

@shirshendu30 Please provide code - HTML, CSS, and JS and the Cypress tests that fail with it. Open a new issue.

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?

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’m also facing this issue(( @jennifer-shehane

Or the hell with cypress .type() and use .text() which never failed me. If in need to type {enter} {esc} etc then .text('sometext').type('{enter}')

Cypress.Commands.add('text', {prevSubject: true}, (subject, text) => {
    subject.val(text)
    return cy.wrap(subject)
})

@KittyGarrison luckily there’s a good amount of suggestions on how to fix this. Here’s a suggestion from Ben @bschley https://github.com/cypress-io/cypress/issues/3817#issuecomment-864113597

Depends on how long it takes to type your warm up text I guess. My worry with wait is that I just don’t like how it smells. If the app takes longer than the wait duration to boot for some reason then we’re back where we started. I feel like typing and clearing is at least interaction with the app so maybe cypress will pick up a different error somehow. Probably not though, this is just conjecture. I just don’t like using lots of waits.

edit: Oh I get you you mean my typing speed. I actually duplicate the whole line twice and change the middle one to a clear() so it’s pretty fast I guess. I’m not that fast a typer.

Here is another workaround which worked for me. I have used tab along with focus and clear to move between input fields.

      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

This is not flaky cypress 4.11.0 has the same issue

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