https://cypress.io logo
i think it would be `window.document.body`
# general-chat
r
i think it would be
window.document.body
l
That's what I thought, but when I try that I get minimal output.
g
because you are in the spec window, you probably want the application's window and document
r
oh, gotcha. Ya, you would need to navigate up the parent chain, find the iframe, and then grab it. This worked for me but not sure if its reliable:
window.parent.document.getElementsByTagName('iFrame').item(0).contentDocument.body
. Cypress grabs a reference to the window in the AUT and makes it available in cy.window and cy.document. Is there a reason why you can't use those in a test?
l
I refactored it to use
cy.document()
but for a moment there I had a more readable way to do it in my head by declaring variables and composing them. This is for a utility function so I was less concerned about sticking to Cypress norms 🙂 Thanks for the answer!
8 Views