Here’s the code sample from our tutorial on how to work with iFrames in Cypress

 

describe("iFrame", () => {
beforeEach(() => {
cy.visit('/ingredients/iframe');
});
it('should find a table in the iframe', () => {
cy.get('#the-kitchen-table').its('0.contentDocument').its('body').then(cy.wrap).find('#fruits-vegetables').should('be.visible');
});
});
view raw iframe.spec.js delivered with ❤ by emgithub

View on GitHub
Colby Fayock
Developer Advocate

Ready for the next generation of testing?

Get started today Schedule a demo