Skip to content
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

Cannot type spaces in email input #1327

Open
jennifer-shehane opened this issue Feb 16, 2018 · 9 comments
Open

Cannot type spaces in email input #1327

jennifer-shehane opened this issue Feb 16, 2018 · 9 comments
Labels
prevent-stale mark an issue so it is ignored by stale[bot] stage: ready for work The issue is reproducible and in scope topic: cy.type ⌨️ topic: native events type: bug

Comments

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Feb 16, 2018

Current behavior:

You can't type spaces within an input of type="email". I came across this while trying to debug #1298

Desired behavior:

Honestly, this likely doesn't matter to anyone because...why are you typing spaces in email fields? But I wanted to document since the behavior differs from typing manually in the browser.

Screen Shot 2019-07-13 at 10 01 51 AM

How to reproduce:

it('test', () => {
  cy.visit('https://example.cypress.io/commands/actions')
  cy.get('input[type="email"]').type('my email')
})
  • Cypress Version: 2.0.0, 3.4.0
@jennifer-shehane jennifer-shehane added type: bug pkg/driver This is due to an issue in the packages/driver directory stage: needs investigating Someone from Cypress needs to look at this labels Feb 16, 2018
@kuceb
Copy link
Contributor

kuceb commented Jul 17, 2018

This is due to type='email' inputs automatically trimming end whitespace when reading off the value property, and will automatically trim the whitespace when setting value directly. Will only really be solved by native events.

@kuceb kuceb added topic: native events and removed pkg/driver This is due to an issue in the packages/driver directory stage: needs investigating Someone from Cypress needs to look at this labels Jul 17, 2018
@jennifer-shehane jennifer-shehane added topic: cy.type ⌨️ stage: ready for work The issue is reproducible and in scope labels Jul 13, 2019
@bbugh
Copy link

bbugh commented Aug 2, 2019

FYI, the example documentation here: https://docs.cypress.io/guides/getting-started/writing-your-first-test.html includes adding a space to an email field, which breaks: [email protected]. This works fine while manually typing in [email protected] but the example spec fails, presumably because of this issue.

describe('My First Test', function () {
  it('Gets, types and asserts', function () {
    cy.visit('https://example.cypress.io')

    cy.contains('type').click()

    // Should be on a new URL which includes '/commands/actions'
    cy.url().should('include', '/commands/actions')

    // Get an input, type into it and verify that the value has been updated
    cy.get('.action-email')
      .type('[email protected ]')     
      .should('have.value', '[email protected]') // ❌ Fails here without space
  })
})

@yktoo
Copy link

yktoo commented Jan 15, 2021

The same seems to apply to <input type="url">. Which is a bit annoying since you can type it in there by hand, but not using Cypress.

@automaticdreams
Copy link

came across this issue today, trying to test validation rules. Given that a real user can type spaces, I need cypress to be able to replicate the behaviour

@tit
Copy link

tit commented Sep 27, 2021

I found some workaround.
Use .invoke('val', 'with space') Instead of .type('with space') for input[type="email"] field.

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 18, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2023
@jchatard
Copy link

This is still an issue in v12.14.0

@lmiller1990
Copy link
Contributor

This will be an issue in core for the foreseeable future since implementing native events is a fairly big change and not something on the roadmap right now.

Good news is this can already work using cypress-real-events. I just tested it out, and it works perfectly. Here's my code:

/// <reference types="cypress" />
describe('page', () => {
  it('works', () => {
    cy.visit('http://localhost:8000')
    cy.get('input').type('a b c') // not working
    cy.get('input').clear().realType('a b c') // works as expected
  })
})

I use cypress-real-events in all my projects, and even internally in the Cypress repo. I'd recommend using it, it's a great library and works beautifully.

Image

@jennifer-shehane jennifer-shehane added prevent-stale mark an issue so it is ignored by stale[bot] and removed stale no activity on this issue for a long period labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prevent-stale mark an issue so it is ignored by stale[bot] stage: ready for work The issue is reproducible and in scope topic: cy.type ⌨️ topic: native events type: bug
Projects
None yet
Development

No branches or pull requests

9 participants