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

226
Vistas
Can't open a link at the same tab using Cypress

I'm trying to open a link in the same tab using cypress

I tired using

cy.get('a').eq(0).invoke('removeAttr', 'target').click()

but it didn't work. after checking the HTML file I saw that there is no

target=_blank

att on the href

I cant understand why its opening on a new window and how to prevent it using cypress.

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

0

For a target=_blank anchor, you can either remove the target attribute or replace the _blank value with _self.

// remove attribute target
cy.get('a')
  .eq(0)
  .should('have.attr', 'target') // check it has target attr before removing
  .invoke('removeAttribute', 'target')
  .click()

// update target value
cy.get('a')
  .eq(0)
  .should('have.attr', 'targe', '_blank') // check target attr has _blank
  .invoke('attr', 'target', '_self')
  .click()
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