grafana/k6

browser: add locator.isInViewport() method

クローズ

#6,022 opened on 2026/05/29

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)Go (1,537 件のフォーク)batch import
browserfeaturegood first issuehacktoberfesttriage

Repository metrics

Stars
 (30,564 個のスター)
PR merge metrics
 (平均マージ 11d 15h) (30d で 47 merged PRs)

説明

Feature Description

k6/browser has no way to detect whether an element intersects the visible viewport. A CTA button can be attached, isVisible() === true, and clickable from k6's perspective, yet rendered below the fold so real users never see it — a silent failure on mobile/responsive sites.

Playwright exposes locator.isInViewport(ratio?) for exactly this case. We don't have an equivalent.

Computing the answer in userland from Locator.BoundingBox() + Page.ViewportSize() is tempting but wrong — it misses scrollable containers, CSS transforms, clip-path, iframes, and DPR/zoom. These are the cases that pushed Playwright off geometry math and onto IntersectionObserver.

Suggested Solution

locator.isInViewport(options?: { ratio?: number, timeout?: number }): Promise<boolean>

Implementation would mirror Playwright's approach — inject IntersectionObserver via Runtime.callFunctionOn — using the existing evalWithScript pattern already used by checkElementState, dispatchEvent, selectOption, etc.

Already existing or connected issues / PRs (optional)

コントリビューターガイド