-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cy.document() does not return an HTMLDocument #29569
Comments
@janakdr I think this is likely due to the HTML Document beind returned from cy.window() being the document within the iframe of the original document, which contains the Cypress interface. |
Thanks for the quick response! The immediate problem this is causing me is that |
@janakdr I haven't encountered this situation exactly, but to get the window of the application under test, I think you'd want to do cy.window().then((win) => {
// work with this win document instead of window.document
}) |
My concern isn't the window per se, it's more about having to change all production code to use an injected document (or window) rather than the global At a basic level, I'm still unclear on why the document from the iframe shouldn't be an |
Current behavior
The following spec fails:
The
window.document
is, as expected, an HTMLDocument, but the doc returned bycy.document()
is not.Test failure message:
Examining the produced document in the console, it looks exactly like an HTMLDocument, it even has an HTMLDocument constructor, but it's not an instanceof HTMLDocument.
I've seen this behavior as far back as Cypress 10.0.0, so it's not a recent regression.
Desired behavior
return an HTMLDocument from cy.document().
Test code to reproduce
See above. I can reproduce in Chrome and Electron, headed and headless.
Cypress Version
13.10.0
Node version
v18.20.3
Operating System
macOS 14.4.1
Debug Logs
Other
No response
The text was updated successfully, but these errors were encountered: