Skip to content

Fix process_frame() returning invalid corsIframes entries when iframe element is not found#126

Merged
bhokaremoin merged 2 commits intoPPLT-4951-responsive-capture-and-cors-iframe-capturefrom
copilot/sub-pr-124
Mar 5, 2026
Merged

Fix process_frame() returning invalid corsIframes entries when iframe element is not found#126
bhokaremoin merged 2 commits intoPPLT-4951-responsive-capture-and-cors-iframe-capturefrom
copilot/sub-pr-124

Conversation

Copy link

Copilot AI commented Mar 5, 2026

process_frame() was returning a result even when the matching <iframe> element wasn't found on the main page, producing corsIframes entries with a null percyElementId that the CLI cannot merge back into the DOM snapshot.

Changes

  • percy/screenshot.py: Added an early-return guard after the page.evaluate() call — if iframe_data is None or lacks percyElementId, the function returns None and logs at debug level instead of propagating an incomplete entry
if not iframe_data or not iframe_data.get("percyElementId"):
    log(
        f"Skipping cross-origin frame {frame_url}: "
        "no matching iframe element with percyElementId found on main page",
        "debug"
    )
    return None
  • tests/test_screenshot.py: Added two new unit tests covering the None iframe_data case and the missing percyElementId case

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ks percyElementId

Co-authored-by: bhokaremoin <75439850+bhokaremoin@users.noreply.github.com>
Copilot AI changed the title [WIP] Update responsive snapshot capture and CORS iframe support Fix process_frame() returning invalid corsIframes entries when iframe element is not found Mar 5, 2026
@bhokaremoin bhokaremoin marked this pull request as ready for review March 5, 2026 07:57
@bhokaremoin bhokaremoin requested a review from a team as a code owner March 5, 2026 07:57
@bhokaremoin bhokaremoin requested review from ninadbstack and rishigupta1599 and removed request for a team March 5, 2026 07:57
@bhokaremoin bhokaremoin merged commit 0eec68d into PPLT-4951-responsive-capture-and-cors-iframe-capture Mar 5, 2026
4 of 7 checks passed
@bhokaremoin bhokaremoin deleted the copilot/sub-pr-124 branch March 5, 2026 07:58
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.

2 participants