`withinFrame` hangs on pages with external iframes (Stripe, etc)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 11.7k
- Forks
- 538
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 8
Description
withinFrame calls waitForLoadState('networkidle') before interacting with the iframe:
https://github.com/pestphp/pest-plugin-browser/blob/4.x/src/Api/Concerns/InteractsWithFrames.php#L21
The problem is that external iframes like Stripe Elements keep persistent connections open, so networkidle never resolves and the test hangs indefinitely.
The next line already calls waitFor(['state' => 'attached']) on the iframe locator, which should be sufficient. The networkidle wait seems unnecessary here.
Workaround I'm using ... manually locate the iframe and construct the Page object, skipping the networkidle wait:
function withinExternalFrame($browser, string $selector, callable $callback)
{
$page = $browser->page();
$locator = $page->locator($selector)->locator('iframe');
$locator->waitFor(['state' => 'attached']);
$contentFrameObj = $locator->contentFrame();
$iframePage = new Pest\Browser\Playwright\Page(
$page->context(),
$contentFrameObj->guid,
$contentFrameObj->guid,
);
$callback(new Pest\Browser\Api\AwaitableWebpage($iframePage, $page->url()));
return $browser;
}
Pest Browser v4.3.0, testing Stripe Elements checkout pages.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/Api/Concerns/InteractsWithFrames.php at line 21 and inspect the network-idle wait before the iframe locator's attached-state wait. Reproduce the behavior with a Stripe Elements or other external iframe page. Done means withinFrame can interact with external iframes without hanging while normal frame handling still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100