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

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

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 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!