-1

I recently started to learn cypress.

I am trying to go to this step but I can t click on that button because it is in an iframe -Go to this URL https://way2automation.com/way2auto_jquery/alert.php#load_box -Click "Input alert" -Click "Click the button to demonstrate the input box"

If I run this I get an error Timed out retrying after 4000ms: cy.its() errored because the property: 0.contentDocument.body does not exist on your subject. cy.its()waited for the specified property 0.contentDocument.body to exist, but it never did. If you do not expect the property 0.contentDocument.body to exist, then add an assertion such as:cy.wrap({ foo: 'bar' }).its('quux').should('not.exist') can someone help me pls?

`/// \<reference types="cypress" /\>
 describe('Frontend tasks', ()=\>{
it('First Task',()=\>{
cy.visit('https://way2automation.com/way2auto_jquery/alert.php#load_box')
cy.contains('Input Alert').click()
cy.get('#example-1-tab-2')
.should('be.visible')
.its('0.contentDocument.body')
.should('not.empty')
.should('not.empty')
.then(cy.wrap)
})
})`
  • 1
    Does this answer your question? [Cypress Iframe Handling - Failure to interact with Button](https://stackoverflow.com/questions/71010936/cypress-iframe-handling-failure-to-interact-with-button) – Paolo Mar 20 '23 at 04:21
  • Does this answer your question? [Cypress e2e testing: How to access new tab by clicking on "href". I don't have target attribute to remove and test on new opened tab?](https://stackoverflow.com/questions/72994758/cypress-e2e-testing-how-to-access-new-tab-by-clicking-on-href-i-dont-have-t) – TesterDick Mar 20 '23 at 04:37

1 Answers1

2

You have a couple of small typos in your test code, but I think if you attempt with the following example instead, you might achieve what you want to do.

cy.get('iframe.demo-frame:eq(1)')
  .its('0.contentDocument.body')
  .should('not.empty')

The <iframe> elements have a class of .demo-frame and you want the second one on the page.