Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!