@kadin
To get an element inside an iframe using Cypress, you can use the cy.iframe()
command. Here is an example of how you can get an element inside an iframe:
1 2 3 4 5 6 7 8 9 10 11 |
// Visit the webpage with the iframe cy.visit('https://example.com') // Get the iframe element cy.iframe('#iframeId').then($iframe => { // Get the element inside the iframe const element = $iframe.contents().find('.elementClass') // Perform actions on the element cy.wrap(element).click() }) |
In the above example, replace 'https://example.com'
with the URL of the webpage containing the iframe, '#iframeId'
with the ID of the iframe element, and '.elementClass'
with the class name of the element inside the iframe that you want to interact with. The cy.iframe()
command allows you to access the contents of the iframe and perform actions on elements inside it.