Skip to content

Commit b4acc56

Browse files
authored
docs(api.md): elaborate on visibility options in waitForSelector (#2208)
Fixes #2202
1 parent 624ca4d commit b4acc56

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

docs/api.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,14 +1811,16 @@ return finalResponse.ok();
18111811
#### page.waitForSelector(selector[, options])
18121812
- `selector` <[string]> A selector of an element to wait for
18131813
- `options` <[Object]>
1814-
- `state` <"attached"|"detached"|"visible"|"hidden"> Wait for element to become visible (`visible`), hidden (`hidden`), present in dom (`attached`) or not present in dom (`detached`). Defaults to `visible`.
1814+
- `state` <"attached"|"detached"|"visible"|"hidden"> Defaults to `'visible'`. Can be either:
1815+
- `'attached'` - wait for element to be present in DOM.
1816+
- `'detached'` - wait for element to not be present in DOM.
1817+
- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible.
1818+
- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`. This is opposite to the `'visible'` option.
18151819
- `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
18161820
- returns: <[Promise]<?[ElementHandle]>> Promise which resolves when element specified by selector satisfies `state` option. Resolves to `null` if waiting for `hidden` or `detached`.
18171821

18181822
Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
18191823

1820-
Element is considered `visible` when it has non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible. Element is considired `hidden` when it is not `visible` as defined above.
1821-
18221824
This method works across navigations:
18231825
```js
18241826
const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
@@ -2435,14 +2437,16 @@ const [response] = await Promise.all([
24352437
#### frame.waitForSelector(selector[, options])
24362438
- `selector` <[string]> A selector of an element to wait for
24372439
- `options` <[Object]>
2438-
- `state` <"attached"|"detached"|"visible"|"hidden"> Wait for element to become visible (`visible`), hidden (`hidden`), present in dom (`attached`) or not present in dom (`detached`). Defaults to `visible`.
2440+
- `state` <"attached"|"detached"|"visible"|"hidden"> Defaults to `'visible'`. Can be either:
2441+
- `'attached'` - wait for element to be present in DOM.
2442+
- `'detached'` - wait for element to not be present in DOM.
2443+
- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible.
2444+
- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`. This is opposite to the `'visible'` option.
24392445
- `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
24402446
- returns: <[Promise]<?[ElementHandle]>> Promise which resolves when element specified by selector satisfies `state` option. Resolves to `null` if waiting for `hidden` or `detached`.
24412447

24422448
Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
24432449

2444-
Element is considered `visible` when it has non-empty bounding box and no `visibility:hidden`. Note that element without any content or with `display:none` has an empty bounding box and is not considered visible. Element is considired `hidden` when it is not `visible` as defined above.
2445-
24462450
This method works across navigations:
24472451
```js
24482452
const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.

0 commit comments

Comments
 (0)