diff --git a/guide/browser/assertion-api.md b/guide/browser/assertion-api.md index d36b248c..149f593b 100644 --- a/guide/browser/assertion-api.md +++ b/guide/browser/assertion-api.md @@ -304,12 +304,12 @@ await expect.element( function toBeInViewport(options: { ratio?: number }): Promise ``` -This allows you to check if an element is currently in viewport with [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API). +允许你通过 [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) 检查元素是否在当前视口中。 -You can pass `ratio` argument as option, which means the minimal ratio of the element should be in viewport. `ratio` should be in 0~1. +你可以通过参数 `ratio`,将视口中元素的最小比例设置为 `ratio`。`ratio` 的取值范围为 0~1。 -该方法通过 IntersectionObserver API检测元素是否位于当前视口内。 -可通过 ratio参数指定元素在视口中的最小可见比例(取值范围为 0~1): +该方法通过 IntersectionObserver API 检测元素是否位于当前视口内。 +可通过 ratio 参数指定元素在视口中的最小可见比例(取值范围为 0~1): ```ts // 检测指定元素是否在视口中 await expect.element(page.getByText('Welcome')).toBeInViewport()