Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda