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

109
Visualizações
How to prevent opening new browser tab for the list of elements?

I am developing Cypress test. And I have <select> element on web page which <option> elements open new page in new browser tab by means of the script containing on the page:

<script>
    $(function () {
        $('#lead-entry-url-dropdown').change(function () {
            var url = $(this).val();
            if (url != null && url != '') {
                window.open(url, "target='_blank'", "noopener");
            }
        });
    });
</script>

Is it possible to remove "target='_blank'" property from the script to avoid opening new browser tab? It is easy to do this for the single element:

cy.get('a').invoke('removeAttr', 'target')

But what about the script? Is it possible to modify it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This describes what you want Stub window.open

const stub = cy.stub().as('open')
cy.on('window:before:load', (win) => {
  cy.stub(win, 'open').callsFake(stub)
})
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