Skip to content

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

Open
chronoAP wants to merge 2 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 2 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
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

2 participants