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

324
Views
Is there an way in cypress to assert a new tab opening without target or remove attribute as i have href as something like this?

I have the element something like this and i am writing the code something like this to click

Then('I click on the Help Icon > {string}', (option) => {
    cy.get('.icon-help').click({ force: true })
    cy.get('ul a')
        .contains(option)
        .click({ force: true })
});

as i need to click first and assert that the page is opening in the next step but the page is opening in a new tab and to remove attribute or _target there is no target attribute.Its completely opening in new tab so how i can assert that the page opening in new tab? enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Since there's no href, it might be that there's a click handler that calls window.open.

If so, stub the call and assert it was called.

cy.get('.icon-help').click({ force: true })

cy.window().then(win => {
  cy.stub(win, 'open').as('open')
})
cy.get('ul a').contains(option).click({ force: true })
cy.get('@open').should('have.been.called')
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!