Skip to content

Fix select_all(include_frames=True) not searching nested iframes#246

Open
chronoAP wants to merge 3 commits intocdpdriver:mainfrom
chronoAP:fix/nested-iframe-query-selector
Open

Fix select_all(include_frames=True) not searching nested iframes#246
chronoAP wants to merge 3 commits intocdpdriver:mainfrom
chronoAP:fix/nested-iframe-query-selector

Conversation

@chronoAP
Copy link
Copy Markdown

@chronoAP chronoAP commented Mar 12, 2026

Description

Originally submitted by: nzxcvz

fqx Verified that it does not find child nodes with find(), and I verified using their test that select_all() has the same behaviour.

Fixes #239
CDP's querySelectorAll only queries within a single document boundary and does not cross into iframe content_document subtrees. This meant elements inside nested iframes were never found.

Walk the full DOM tree to collect each iframe's content_document and query them individually.

Also fixed an issue I had related to this function during use, and something I noticed while snooping the code base: add a guard for cross-origin iframes where content_document is None, and fixes the fullscreen() docstring.

Pre-merge Checklist

  • I have described my change in the section above.
  • I have ran the ./scripts/format.sh and ./scripts/lint.sh scripts. My code is properly formatted and has no linting errors.
  • I have ran uv run pytest and ensured all tests pass.
  • I have added my change to CHANGELOG.md under the [Unreleased] section.

CDP's querySelectorAll only queries within a single document boundary
and does not cross into iframe content_document subtrees. This meant
elements inside nested iframes were never found.

Walk the full DOM tree to collect each iframe's content_document and
query them individually. Also adds a guard for cross-origin iframes
where content_document is None, and fixes the fullscreen() docstring.
@chronoAP chronoAP requested a review from a team as a code owner March 12, 2026 17:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

❌ Patch coverage is 19.23077% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
zendriver/core/tab.py 19.23% 21 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Member

@stephanlensky stephanlensky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chronoAP, this change looks great to me. Sorry for the delayed response, I've been pretty busy at work and haven't had as much time to spend on this project.

Would you be open to adding a unit test to verify the fix works?

@chronoAP
Copy link
Copy Markdown
Author

Thanks @chronoAP, this change looks great to me. Sorry for the delayed response, I've been pretty busy at work and haven't had as much time to spend on this project.

Would you be open to adding a unit test to verify the fix works?

No worries at all.

Sure, I could give it a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

I frame

3 participants