Skip to content

# withinFrame hangs on pages with external iframes (Stripe, etc.) #1625

@mauricekindermann

Description

@mauricekindermann

FYI.- I will try and PR this later in the week. Mansoor did the original WithinFrame, I will discuss with him privately. I've fixed locally with a custom method until I can switch back - Stripe fails locally and in CI without it.


withinFrame calls waitForLoadState('networkidle') before entering the iframe. External iframes like Stripe Payment Element make continuous network requests, so networkidle never resolves and the browser context dies with:

Target page, context or browser has been closed

Fix

In InteractsWithFrames.php, replace networkidle with load:

- $this->page->waitForLoadState('networkidle');
+ $this->page->waitForLoadState('load');

The waitFor(['state' => 'attached']) on the next line already ensures the iframe is ready.

Also, frameLocator($selector) double-nests the selector when the target is a container div (not the iframe itself). Simpler:

- $locator = $this->guessLocator($selector)->frameLocator($selector);
+ $locator = $this->guessLocator($selector)->locator('iframe');

Workaround

We're using a helper that replicates withinFrame without the networkidle wait until this is fixed upstream.

pest-plugin-browser v4.1.1, macOS, Chromium headless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions