Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Handling iFrames using Cypress

Category: Cypress
Option 1:
let iframe = cy.get('#iFrameID')
                         .its('0.contentDocument.body')
                         .should('be.visible')
                         .then('cy.wrap');

iframe.clear().type('Welcome to Hire QA');

Option 2:
Install cypress-iframe plugin - npm install -D cypress-iframe
Add the command in cypress/support/command.js : import 'cypress-iframe'
Load the frame or switch to the frame: cy.frameLoaded('#frameID')

Leave a Reply

Your email address will not be published. Required fields are marked *