Skip to content

browser: Add frameLocator() method - #5487

Merged
ankur22 merged 5 commits into
grafana:masterfrom
pkalsi97:feat/5177
Jan 19, 2026
Merged

browser: Add frameLocator() method#5487
ankur22 merged 5 commits into
grafana:masterfrom
pkalsi97:feat/5177

Conversation

@pkalsi97

Copy link
Copy Markdown
Contributor

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

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • 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
pkalsi97 requested a review from a team as a code owner December 11, 2025 11:51
@pkalsi97
pkalsi97 requested review from joanlopez and mstoykov and removed request for a team December 11, 2025 11:51
@pkalsi97 pkalsi97 changed the title browser: Add frameLocator() method to Page, Frame, Locator and FrameLocator objects browser: Add frameLocator() method Dec 11, 2025
@pkalsi97
pkalsi97 temporarily deployed to azure-trusted-signing January 6, 2026 11:20 — with GitHub Actions Inactive
@pkalsi97
pkalsi97 temporarily deployed to azure-trusted-signing January 6, 2026 11:21 — with GitHub Actions Inactive
@ankur22
ankur22 self-requested a review January 15, 2026 14:15
ankur22
ankur22 previously approved these changes Jan 15, 2026

@ankur22 ankur22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 Thanks for this change!

Left some minor things that would be good if they were addressed but functionally looks correct to me.

Comment thread internal/js/modules/k6/browser/tests/locator_test.go
Comment thread examples/browser/framelocator.js Outdated
@pkalsi97

Copy link
Copy Markdown
Contributor Author

@ankur22 Thanks for the review, i have addressed the above. :)

i have two concerns

  1. browser: add page.on('requestfinished') event handler #5486 this PR introduced the page.on('requestfinished') , but some how the ci did not catch the lint issue now that lint issue is showing up in this branch as well as it was updated.
Running linters...
internal/js/modules/k6/browser/browser/page_mapping.go:645:5: missing cases in switch of type common.PageEventName: common.PageEventRequestFinished (exhaustive)
                                switch event {
                                ^
1 issues:
* exhaustive: 1
make: *** [lint] Error 1
  1. I would request you to block the merger of browser: address frameLocator PR review comments #5489 to prevent big conflict, merge this one first when ever you see fit.

@pkalsi97
pkalsi97 temporarily deployed to azure-trusted-signing January 16, 2026 09:18 — with GitHub Actions Inactive
@pkalsi97
pkalsi97 temporarily deployed to azure-trusted-signing January 16, 2026 09:20 — with GitHub Actions Inactive
@pkalsi97
pkalsi97 temporarily deployed to azure-trusted-signing January 16, 2026 11:59 — with GitHub Actions Inactive
@pkalsi97
pkalsi97 temporarily deployed to azure-trusted-signing January 16, 2026 12:01 — with GitHub Actions Inactive
@ankur22
ankur22 temporarily deployed to azure-trusted-signing January 19, 2026 10:16 — with GitHub Actions Inactive
@ankur22
ankur22 temporarily deployed to azure-trusted-signing January 19, 2026 10:18 — with GitHub Actions Inactive
@ankur22
ankur22 merged commit 20541e1 into grafana:master Jan 19, 2026
40 of 48 checks passed
@mstoykov mstoykov added this to the v1.6.0 milestone Jan 21, 2026
joanlopez added a commit to grafana/k6-docs that referenced this pull request Feb 10, 2026
joanlopez added a commit to grafana/k6-docs that referenced this pull request Feb 10, 2026
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: page|frameLocator|locator.frameLocator

3 participants