As you might know, Cypress is a problem and there is a lot of stuff written down. But because I didn’t make it work with one article, we need another one! I made it work with our payment plugin for Montonio so here it goes:
Security? Who needs this anyway!?
First step is to turn off security. Our browsers nowadays are more and more secure and one of the things is, that you can’t access content of iframes if they don’t like it – and you can bet that payment provider turn on security. But this doesn’t help for testing, so don’t do that for your daily life! But running tests in a less secure environment is fine. Or in other words:
Learn the rules like a pro, so you can break them like an artist.
Add require ('cypress-iframe') to cypress/support/e2e.js
Use it
Access iframes on foreign pages
Because the payment works via redirect, we needed to access the page via cy.origin and inside of an origin block we are not allowed to use other npm packages, except we specify them with Cypress.require.