Skip to content

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented May 22, 2025

Description

Fixes #6966

This PR supports iframe user events, bu doesn't support expect assertions because they rely on walking the DOM and not CDP.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented May 22, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit cebc0ad
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/68af2b38bc578f0007a8eaf7
😎 Deploy Preview https://deploy-preview-8016--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sheremet-va sheremet-va changed the title feat(browser): support iframe locator in playwright feat(browser): support iframe locator with playwright provider May 22, 2025
@acaldas
Copy link

acaldas commented May 26, 2025

Hi @sheremet-va, I'd like to work on supporting expect assertions on the Iframe.
Is there a fundamental blocker that makes it not possible? At least if the Iframe is on the same domain.

Does it need to be done at the framework adapter level?
Initially I was looking at vitest-browser-react.
If you could give me some pointers on where to start I'd appreciate it.

I promise I won't just do a PR with AI slop 😄 .

@sheremet-va
Copy link
Member Author

sheremet-va commented May 26, 2025

Hi @sheremet-va, I'd like to work on supporting expect assertions on the Iframe. Is there a fundamental blocker that makes it not possible? At least if the Iframe is on the same domain.

Does it need to be done at the framework adapter level? Initially I was looking at vitest-browser-react. If you could give me some pointers on where to start I'd appreciate it.

I promise I won't just do a PR with AI slop 😄 .

The locator support is provided via ivya package. The implementation should work the same way as playwright. Playwright does support click here, which suggests that it also supports traversing the DOM. Why it doesn't work at the moment, I don't know.

Basically, to make expect work, we need this to not fail:

const frame = page.frameLocator(page.getByTestId('iframe'))
frame.getByText('Hello World').element() // right now fails

@sheremet-va sheremet-va marked this pull request as ready for review August 27, 2025 16:50
@sheremet-va sheremet-va merged commit 57b2cca into vitest-dev:main Aug 28, 2025
12 of 14 checks passed
@sheremet-va sheremet-va deleted the feat/browser-support-iframe-locator branch August 28, 2025 08:38
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.

Browser Mode - Add an API for accessing content rendered in iframes
2 participants