Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

240
Vistas
How to hold shift and use arrow keys in Cypress

I have an issue when using the Cypress type() command in the way I want.

My objective

I want to be able to select and delete text in a textfield. I want this done via holding the shift key, pressing the right arrow key multiple times and then pressing the delete key.

My attempt

//hold shift and use right arrow
cy.type('{shift}{rightarrow}'.repeat(10));
//press delete
cy.type('{del}');

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

As per the available information instead of repeat, you can use the Cypress._.times loadash method. This will run the entire type command 10 times.

Cypress._.times(10, () => {
  cy.type('{shift}{rightarrow}')
})
about 4 years ago · Juan Pablo Isaza Denunciar

0

The element needs focus before applying arrow keys,

cy.get('#myinput')
  .focus()
  .type(Cypress._.repeat('{shift}{rightarrow}', 5))
  .type('{del}')

This gets the cursor moving within the the element's text, but unfortunately does not extend the selection, so {del} only removes one element.

You can use an internal input method instead of {shift}{rightarrow}, if this suits your test

cy.get('#myinput')
  .focus()
  .then($el => $el[0].setSelectionRange(0, 5))
  .type('{del}')

To clear completely,

cy.get('#myinput')
  .clear()          // types {selectall}{del}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda