You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`selector` <[string]> A selector to query page for
688
-
-`pageFunction` <[function]\([Element]\)> Function to be evaluated in browser context
689
-
-`options` <[Object]> Optional waiting parameters
690
-
-`polling` <[number]|"raf"|"mutation"> An interval at which the `pageFunction` is executed, defaults to `raf`. If `polling` is a number, then it is treated as an interval in milliseconds at which the function would be executed. If `polling` is a string, then it can be one of the following values:
691
-
-`'raf'` - to constantly execute `pageFunction` in `requestAnimationFrame` callback. This is the tightest polling mode which is suitable to observe styling changes.
692
-
-`'mutation'` - to execute `pageFunction` on every DOM mutation.
693
-
-`timeout` <[number]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
694
-
-`...args` <...[Serializable]|[JSHandle]> Arguments to pass to `pageFunction`
695
-
- returns: <[Promise]<[JSHandle]>> Promise which resolves to a JSHandle of the success value
686
+
#### page.$wait(selector[, options])
687
+
-`selector` <[string]> A selector of an element to wait for
688
+
-`options` <[Object]>
689
+
-`visibility` <"visible"|"hidden"|"any"> Wait for element to become visible (`visible`), hidden (`hidden`), present in dom (`any`). Defaults to `any`.
690
+
-`timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
691
+
- returns: <[Promise]<?[ElementHandle]>> Promise which resolves when element specified by selector string is added to DOM. Resolves to `null` if waiting for `hidden: true` and selector is not found in DOM.
696
692
697
-
This method runs `document.querySelector` within the page and passes it as the first argument to `pageFunction`. If there's no element matching `selector`, the method throws an error.
693
+
Wait for the `selector` to appear in page. If at the moment of calling
694
+
the method the `selector` already exists, the method will return
695
+
immediately. If the selector doesn't appear after the `timeout` milliseconds of waiting, the function will throw.
698
696
699
-
If `pageFunction` returns a [Promise], then `page.$wait` would wait for the promise to resolve and return its value. The function
700
-
is being called on the element periodically until either timeout expires or the function returns the truthy value.
697
+
This method works across navigations:
698
+
```js
699
+
consthandle=awaitpage.$wait(selector);
700
+
awaithandle.click();
701
+
```
701
702
702
-
Shortcut for [page.mainFrame().$wait(selector, pageFunction[, options[, ...args]])](#framewaitselector-pagefunction-options-args).
703
+
This is a shortcut to [page.waitForSelector(selector[, options])](#pagewaitforselectorselector-options).
703
704
704
705
#### page.accessibility
705
706
- returns: <[Accessibility]>
@@ -1668,7 +1669,7 @@ An example of getting text from an iframe element:
-`selector` <[string]> A selector to query page for
1749
-
-`pageFunction` <[function]\([Element]\)> Function to be evaluated in browser context
1750
-
-`options` <[Object]> Optional waiting parameters
1751
-
-`polling` <[number]|"raf"|"mutation"> An interval at which the `pageFunction` is executed, defaults to `raf`. If `polling` is a number, then it is treated as an interval in milliseconds at which the function would be executed. If `polling` is a string, then it can be one of the following values:
1752
-
-`'raf'` - to constantly execute `pageFunction` in `requestAnimationFrame` callback. This is the tightest polling mode which is suitable to observe styling changes.
1753
-
-`'mutation'` - to execute `pageFunction` on every DOM mutation.
1754
-
-`timeout` <[number]> maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
1755
-
-`...args` <...[Serializable]|[JSHandle]> Arguments to pass to `pageFunction`
1756
-
- returns: <[Promise]<[JSHandle]>> Promise which resolves to a JSHandle of the success value
1748
+
#### frame.$wait(selector[, options])
1749
+
-`selector` <[string]> A selector of an element to wait for
1750
+
-`options` <[Object]>
1751
+
-`visibility` <"visible"|"hidden"|"any"> Wait for element to become visible (`visible`), hidden (`hidden`), present in dom (`any`). Defaults to `any`.
1752
+
-`timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
1753
+
- returns: <[Promise]<?[ElementHandle]>> Promise which resolves when element specified by selector string is added to DOM. Resolves to `null` if waiting for `hidden: true` and selector is not found in DOM.
1757
1754
1758
-
This method runs `document.querySelector` within the frame and passes it as the first argument to `pageFunction`. If there's no element matching `selector`, the method throws an error.
1755
+
Wait for the `selector` to appear in page. If at the moment of calling
1756
+
the method the `selector` already exists, the method will return
1757
+
immediately. If the selector doesn't appear after the `timeout` milliseconds of waiting, the function will throw.
1758
+
1759
+
This method works across navigations:
1760
+
```js
1761
+
consthandle=awaitpage.$wait(selector);
1762
+
awaithandle.click();
1763
+
```
1759
1764
1760
-
If `pageFunction` returns a [Promise], then `page.$wait` would wait for the promise to resolve and return its value. The function
1761
-
is being called on the element periodically until either timeout expires or the function returns the truthy value.
1765
+
This is a shortcut to [frame.waitForSelector(selector[, options])](#framewaitforselectorselector-options).
0 commit comments