k6 icon indicating copy to clipboard operation
k6 copied to clipboard

browser: Add `frameLocator()` method

Open pkalsi97 opened this issue 2 weeks ago • 0 comments

What?

This PR Add frameLocator() method to Page, Frame, Locator, and FrameLocator objects. This is a shorthand for locator(selector).contentFrame() providing a more concise API for working with iframes.

Usage
  // Before
  const frame = page.locator('#my-iframe').contentFrame();
  const button = frame.locator('#submit-btn');

  // After
  const button = page.frameLocator('#my-iframe').locator('#submit-btn');

 // Nested iframes are also supported:
  page.frameLocator('#outer').frameLocator('#inner').locator('button')

Why?

Issue #5177 Describes the need for a convince method.

Checklist

  • [x] I have performed a self-review of my code.
  • [x] I have commented on my code, particularly in hard-to-understand areas.
  • [x] I have added tests for my changes.
  • [x] I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • [ ] I have added the correct milestone and labels to the PR.
  • [ ] I have updated the release notes: link
  • [ ] I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • [ ] I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Closes #5177

pkalsi97 avatar Dec 11 '25 11:12 pkalsi97