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
-`selectorOrFunctionOrTimeout` <[string]|[number]|[function]> A [selector], predicate or timeout to wait for
1693
-
-`options` <[Object]> Optional waiting parameters
1694
-
-`waitFor` <"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 `attached`.
1695
-
-`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:
1696
-
-`'raf'` - to constantly execute `pageFunction` in `requestAnimationFrame` callback. This is the tightest polling mode which is suitable to observe styling changes.
1697
-
-`'mutation'` - to execute `pageFunction` on every DOM mutation.
1698
-
-`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 [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
1699
-
-`arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
1700
-
- returns: <[Promise]<?[JSHandle]>> Promise which resolves to a JSHandle of the success value
1701
-
1702
-
This method behaves differently with respect to the type of the first parameter:
1703
-
- if `selectorOrFunctionOrTimeout` is a `string`, then the first argument is treated as a [selector] and the method is a shortcut for [page.waitForSelector](#pagewaitforselectorselector-options)
1704
-
- if `selectorOrFunctionOrTimeout` is a `function`, then the first argument is treated as a predicate to wait for and the method is a shortcut for [page.waitForFunction()](#pagewaitforfunctionpagefunction-arg-options).
1705
-
- if `selectorOrFunctionOrTimeout` is a `number`, then the first argument is treated as a timeout in milliseconds and the method returns a promise which resolves after the timeout
-`event` <[string]> Event name, same one would pass into `page.on(event)`.
1728
1693
-`optionsOrPredicate` <[Function]|[Object]> Either a predicate that receives an event or an options object.
@@ -1871,7 +1836,22 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.
1871
1836
awaitbrowser.close();
1872
1837
})();
1873
1838
```
1874
-
Shortcut for [page.mainFrame().waitForSelector(selector[, options])](#framewaitforselectororfunctionortimeout-options-arg).
1839
+
Shortcut for [page.mainFrame().waitForSelector(selector[, options])](#framewaitforselectorselector-options).
1840
+
1841
+
#### page.waitForTimeout(timeout)
1842
+
-`timeout` <[number]> A timeout to wait for
1843
+
- returns: <[Promise]>
1844
+
1845
+
Returns a promise that resolves after the timeout.
1846
+
1847
+
Note that `page.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be flaky. Use signals such as network events, selectors becoming visible and others instead.
1848
+
1849
+
```js
1850
+
// wait for 1 second
1851
+
awaitpage.waitForTimeout(1000);
1852
+
```
1853
+
1854
+
Shortcut for [page.mainFrame().waitForTimeout(timeout)](#pagewaitfortimeouttimeout).
1875
1855
1876
1856
#### page.workers()
1877
1857
- returns: <[Array]<[Worker]>>
@@ -1948,11 +1928,11 @@ An example of getting text from an iframe element:
-`selectorOrFunctionOrTimeout` <[string]|[number]|[function]> A [selector], predicate or timeout to wait for
2390
-
-`options` <[Object]> Optional waiting parameters
2391
-
-`waitFor` <"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 `attached`.
2392
-
-`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:
2393
-
-`'raf'` - to constantly execute `pageFunction` in `requestAnimationFrame` callback. This is the tightest polling mode which is suitable to observe styling changes.
2394
-
-`'mutation'` - to execute `pageFunction` on every DOM mutation.
2395
-
-`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 [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
2396
-
-`arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
2397
-
- returns: <[Promise]<?[JSHandle]>> Promise which resolves to a JSHandle of the success value
2398
-
2399
-
This method behaves differently with respect to the type of the first parameter:
2400
-
- if `selectorOrFunctionOrTimeout` is a `string`, then the first argument is treated as a [selector] and the method is a shortcut for [frame.waitForSelector](#framewaitforselectororfunctionortimeout-options-arg)
2401
-
- if `selectorOrFunctionOrTimeout` is a `function`, then the first argument is treated as a predicate to wait for and the method is a shortcut for [frame.waitForFunction()](#framewaitforfunctionpagefunction-arg-options).
2402
-
- if `selectorOrFunctionOrTimeout` is a `number`, then the first argument is treated as a timeout in milliseconds and the method returns a promise which resolves after the timeout
-`pageFunction` <[function]|[string]> Function to be evaluated in browser context
2423
2370
-`arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
@@ -2514,6 +2461,14 @@ const { webkit } = require('playwright'); // Or 'chromium' or 'firefox'.
2514
2461
})();
2515
2462
```
2516
2463
2464
+
#### frame.waitForTimeout(timeout)
2465
+
-`timeout` <[number]> A timeout to wait for
2466
+
- returns: <[Promise]>
2467
+
2468
+
Returns a promise that resolves after the timeout.
2469
+
2470
+
Note that `frame.waitForTimeout()` should only be used for debugging. Tests using the timer in production are going to be flaky. Use signals such as network events, selectors becoming visible and others instead.
0 commit comments