Skip to content

feat: add frameLocator support for cross-origin iframe interaction#460

Open
giulio-leone wants to merge 1 commit intovercel-labs:mainfrom
giulio-leone:feat/279-frame-locator
Open

feat: add frameLocator support for cross-origin iframe interaction#460
giulio-leone wants to merge 1 commit intovercel-labs:mainfrom
giulio-leone:feat/279-frame-locator

Conversation

@giulio-leone
Copy link

Summary

Add a new framelocator action that uses Playwright's frameLocator() API to enable interaction with cross-origin iframes. The existing frame command uses page.frame() / contentFrame() which doesn't work across origins due to browser security restrictions.

Changes

  • src/browser.ts: Add activeFrameLocator property, setFrameLocator() method, and modify getLocator() to scope through frameLocator() when active. Also clear frame locator when switchToMainFrame() is called.
  • src/types.ts: Add FrameLocatorCommand interface
  • src/protocol.ts: Add framelocator schema to validation and discriminated union
  • src/actions.ts: Add framelocator case in dispatch and handleFrameLocator handler
  • cli/src/commands.rs: Add frame locator <selector> CLI parsing

Usage

# Set frame locator for a cross-origin iframe
frame locator iframe#payment

# Now all subsequent commands target elements inside the iframe
click button#submit
fill input#card-number 4242424242424242

# Return to main frame
frame main

How it works

Playwright's frameLocator() is a lazy API that doesn't require the frame to be loaded at the time of the call and works with cross-origin iframes (unlike frame()). When a frame locator is active, getLocator() scopes all element lookups through page.frameLocator(selector).locator(...).

Closes #279

Add a new 'framelocator' action that uses Playwright's frameLocator() API
to enable interaction with cross-origin iframes. The existing 'frame' command
uses page.frame() which doesn't work across origins.

Changes:
- browser.ts: Add activeFrameLocator property, setFrameLocator() method,
  and modify getLocator() to scope through frameLocator when active
- types.ts: Add FrameLocatorCommand interface
- protocol.ts: Add framelocator schema
- actions.ts: Add framelocator case and handler
- commands.rs: Add 'frame locator <selector>' CLI parsing

Closes vercel-labs#279
@vercel
Copy link
Contributor

vercel bot commented Feb 13, 2026

@g97iulio1609 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

Feature Request: Add frameLocator support for cross-origin iframe interaction

1 participant