After removing attribute _target, new url is opened under iframe

Viewed 35

Technologies: Cypress/Typescript

I am trying to remove target _blank from <a> element and to open new url in the same tab, but since that <a> is under the iframe, new url is opened in iframe, is there any solution for the issue.

getIframeBody()
  .find('table#emailContainer tr td a')
  .invoke('removeAttr','target')
  .click();
1 Answers

How about you get the href attribute and then just visit it? For example:

getIframeBody().find('table#emailContainer tr td a').invoke('attr', 'href').then((href) => {
    cy.visit(href)
    // rest of the test
})
Related