I am trying to click on a link that is within iframe in Cypress. The link opens in the next tab and the test fails.
cy.get('iframe.body').wait(1000).its('0.contentDocument.body')
.find('a').contains('Click').click();
To fix the issue used something like this to make the new page open on the same tab. But its not working:
cy.get('iframe.body').wait(1000).its('0.contentDocument.body')
.find('a').contains('Click')
.invoke('removeAttr', 'target').click();
Element looks something like this:
<iframe class="body" data-flexie-id="3" data-flexie-parent="true" src="messages/1.html" style="">
</iframe>
<p>
<a href="https://Thisisalink/91cf-a6c3792a5cc5" target="_blank">Click</a>
</p>