grafana/k6

Add `ElementHandle.isInViewport()`

开放

#4,423 创建于 2022年8月12日

 (3 条评论) (0 个反应) (1 位负责人)Go (1,537 个派生)batch import
area: browserfeaturegood first issuehacktoberfesttriage

仓库指标

星标
 (30,564 个星标)
PR 合并指标
 (平均合并 11天 15小时) (30 天内合并 47 个 PR)

描述

From this discussion in grafana/xk6-browser#467, we wanted to change TestWaitForFrameNavigationWithinDocument to also check whether an element is visible within the viewport after a navigation in the same document happens.

To do that it would be helpful if there was an ElementHandle.isInViewport() method, similar to the one described here. Playwright doesn't have such a method, but Puppeteer has ElementHandle.isIntersectingViewport(). isInViewport seems like a slightly better name, so let's go with that.

Suggested solution

We already have ElementHandle.boundingBox() in Go, though if we want to reduce the amount of JS evaluations and CDP calls, we could just wrap ElementHandle.eval() and do a single CDP call for this.

See grafana/k6#4424 for the test change to use this method.

贡献者指南