@@ -819,7 +819,7 @@ async def press(self, key: str, *, delay: float = None) -> NoneType:
819
819
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
820
820
texts.
821
821
822
- Shortcuts such as `key: \" Control+o\" ` or `key: \" Control+Shift+T\" ` are supported as well. When speficied with the
822
+ Shortcuts such as `key: \" Control+o\" ` or `key: \" Control+Shift+T\" ` are supported as well. When specified with the
823
823
modifier, modifier is pressed and being held while the subsequent key is being pressed.
824
824
825
825
```py
@@ -1390,8 +1390,8 @@ async def dispatch_event(
1390
1390
) -> NoneType :
1391
1391
"""ElementHandle.dispatch_event
1392
1392
1393
- The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
1394
- is dispatched. This is equivalend to calling
1393
+ The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
1394
+ `click` is dispatched. This is equivalent to calling
1395
1395
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
1396
1396
1397
1397
```py
@@ -1948,7 +1948,7 @@ async def press(
1948
1948
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
1949
1949
texts.
1950
1950
1951
- Shortcuts such as `key: \" Control+o\" ` or `key: \" Control+Shift+T\" ` are supported as well. When speficied with the
1951
+ Shortcuts such as `key: \" Control+o\" ` or `key: \" Control+Shift+T\" ` are supported as well. When specified with the
1952
1952
modifier, modifier is pressed and being held while the subsequent key is being pressed.
1953
1953
1954
1954
Parameters
@@ -2709,6 +2709,47 @@ def expect_navigation(
2709
2709
).future
2710
2710
)
2711
2711
2712
+ async def wait_for_url (
2713
+ self ,
2714
+ url : typing .Union [str , typing .Pattern , typing .Callable [[str ], bool ]],
2715
+ * ,
2716
+ wait_until : Literal ["domcontentloaded" , "load" , "networkidle" ] = None ,
2717
+ timeout : float = None
2718
+ ) -> NoneType :
2719
+ """Frame.wait_for_url
2720
+
2721
+ Waits for the frame to navigate to the given URL.
2722
+
2723
+ ```py
2724
+ await frame.click(\" a.delayed-navigation\" ) # clicking the link will indirectly cause a navigation
2725
+ await frame.wait_for_url(\" **/target.html\" )
2726
+ ```
2727
+
2728
+ Parameters
2729
+ ----------
2730
+ url : Union[Callable[[str], bool], Pattern, str]
2731
+ A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation.
2732
+ wait_until : Union["domcontentloaded", "load", "networkidle", NoneType]
2733
+ When to consider operation succeeded, defaults to `load`. Events can be either:
2734
+ - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
2735
+ - `'load'` - consider operation to be finished when the `load` event is fired.
2736
+ - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
2737
+ timeout : Union[float, NoneType]
2738
+ Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be
2739
+ changed by using the `browser_context.set_default_navigation_timeout()`,
2740
+ `browser_context.set_default_timeout()`, `page.set_default_navigation_timeout()` or
2741
+ `page.set_default_timeout()` methods.
2742
+ """
2743
+
2744
+ return mapping .from_maybe_impl (
2745
+ await self ._async (
2746
+ "frame.wait_for_url" ,
2747
+ self ._impl_obj .wait_for_url (
2748
+ url = self ._wrap_handler (url ), wait_until = wait_until , timeout = timeout
2749
+ ),
2750
+ )
2751
+ )
2752
+
2712
2753
async def wait_for_load_state (
2713
2754
self ,
2714
2755
state : Literal ["domcontentloaded" , "load" , "networkidle" ] = None ,
@@ -3169,8 +3210,8 @@ async def dispatch_event(
3169
3210
) -> NoneType :
3170
3211
"""Frame.dispatch_event
3171
3212
3172
- The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
3173
- is dispatched. This is equivalend to calling
3213
+ The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
3214
+ `click` is dispatched. This is equivalent to calling
3174
3215
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
3175
3216
3176
3217
```py
@@ -4089,7 +4130,7 @@ async def press(
4089
4130
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
4090
4131
texts.
4091
4132
4092
- Shortcuts such as `key: \" Control+o\" ` or `key: \" Control+Shift+T\" ` are supported as well. When speficied with the
4133
+ Shortcuts such as `key: \" Control+o\" ` or `key: \" Control+Shift+T\" ` are supported as well. When specified with the
4093
4134
modifier, modifier is pressed and being held while the subsequent key is being pressed.
4094
4135
4095
4136
Parameters
@@ -4894,6 +4935,7 @@ def set_default_navigation_timeout(self, timeout: float) -> NoneType:
4894
4935
- `page.reload()`
4895
4936
- `page.set_content()`
4896
4937
- `page.expect_navigation()`
4938
+ - `page.wait_for_url()`
4897
4939
4898
4940
> NOTE: `page.set_default_navigation_timeout()` takes priority over `page.set_default_timeout()`,
4899
4941
`browser_context.set_default_timeout()` and `browser_context.set_default_navigation_timeout()`.
@@ -5210,8 +5252,8 @@ async def dispatch_event(
5210
5252
) -> NoneType :
5211
5253
"""Page.dispatch_event
5212
5254
5213
- The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the elment, `click`
5214
- is dispatched. This is equivalend to calling
5255
+ The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element,
5256
+ `click` is dispatched. This is equivalent to calling
5215
5257
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
5216
5258
5217
5259
```py
@@ -5904,6 +5946,49 @@ async def wait_for_load_state(
5904
5946
)
5905
5947
)
5906
5948
5949
+ async def wait_for_url (
5950
+ self ,
5951
+ url : typing .Union [str , typing .Pattern , typing .Callable [[str ], bool ]],
5952
+ * ,
5953
+ wait_until : Literal ["domcontentloaded" , "load" , "networkidle" ] = None ,
5954
+ timeout : float = None
5955
+ ) -> NoneType :
5956
+ """Page.wait_for_url
5957
+
5958
+ Waits for the main frame to navigate to the given URL.
5959
+
5960
+ ```py
5961
+ await page.click(\" a.delayed-navigation\" ) # clicking the link will indirectly cause a navigation
5962
+ await page.wait_for_url(\" **/target.html\" )
5963
+ ```
5964
+
5965
+ Shortcut for main frame's `frame.wait_for_url()`.
5966
+
5967
+ Parameters
5968
+ ----------
5969
+ url : Union[Callable[[str], bool], Pattern, str]
5970
+ A glob pattern, regex pattern or predicate receiving [URL] to match while waiting for the navigation.
5971
+ wait_until : Union["domcontentloaded", "load", "networkidle", NoneType]
5972
+ When to consider operation succeeded, defaults to `load`. Events can be either:
5973
+ - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
5974
+ - `'load'` - consider operation to be finished when the `load` event is fired.
5975
+ - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
5976
+ timeout : Union[float, NoneType]
5977
+ Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be
5978
+ changed by using the `browser_context.set_default_navigation_timeout()`,
5979
+ `browser_context.set_default_timeout()`, `page.set_default_navigation_timeout()` or
5980
+ `page.set_default_timeout()` methods.
5981
+ """
5982
+
5983
+ return mapping .from_maybe_impl (
5984
+ await self ._async (
5985
+ "page.wait_for_url" ,
5986
+ self ._impl_obj .wait_for_url (
5987
+ url = self ._wrap_handler (url ), wait_until = wait_until , timeout = timeout
5988
+ ),
5989
+ )
5990
+ )
5991
+
5907
5992
async def wait_for_event (
5908
5993
self , event : str , predicate : typing .Callable = None , * , timeout : float = None
5909
5994
) -> typing .Any :
@@ -6163,7 +6248,7 @@ async def route(
6163
6248
6164
6249
> NOTE: The handler will only be called for the first url if the response is a redirect.
6165
6250
6166
- An example of a naïve handler that aborts all image requests:
6251
+ An example of a naive handler that aborts all image requests:
6167
6252
6168
6253
```py
6169
6254
page = await browser.new_page()
@@ -6184,6 +6269,8 @@ async def route(
6184
6269
Page routes take precedence over browser context routes (set up with `browser_context.route()`) when request
6185
6270
matches both handlers.
6186
6271
6272
+ To remove a route with its handler you can use `page.unroute()`.
6273
+
6187
6274
> NOTE: Enabling routing disables http cache.
6188
6275
6189
6276
Parameters
@@ -6247,9 +6334,6 @@ async def screenshot(
6247
6334
6248
6335
Returns the buffer with the captured screenshot.
6249
6336
6250
- > NOTE: Screenshots take at least 1/6 second on Chromium OS X and Chromium Windows. See https://crbug.com/741689 for
6251
- discussion.
6252
-
6253
6337
Parameters
6254
6338
----------
6255
6339
timeout : Union[float, NoneType]
@@ -7001,7 +7085,7 @@ async def press(
7001
7085
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
7002
7086
texts.
7003
7087
7004
- Shortcuts such as `key: \" Control+o\" ` or `key: \" Control+Shift+T\" ` are supported as well. When speficied with the
7088
+ Shortcuts such as `key: \" Control+o\" ` or `key: \" Control+Shift+T\" ` are supported as well. When specified with the
7005
7089
modifier, modifier is pressed and being held while the subsequent key is being pressed.
7006
7090
7007
7091
```py
@@ -8190,7 +8274,7 @@ async def route(
8190
8274
Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
8191
8275
is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
8192
8276
8193
- An example of a naïve handler that aborts all image requests:
8277
+ An example of a naive handler that aborts all image requests:
8194
8278
8195
8279
```py
8196
8280
context = await browser.new_context()
@@ -8214,6 +8298,8 @@ async def route(
8214
8298
Page routes (set up with `page.route()`) take precedence over browser context routes when request matches both
8215
8299
handlers.
8216
8300
8301
+ To remove a route with its handler you can use `browser_context.unroute()`.
8302
+
8217
8303
> NOTE: Enabling routing disables http cache.
8218
8304
8219
8305
Parameters
@@ -8553,6 +8639,7 @@ async def new_context(
8553
8639
self ,
8554
8640
* ,
8555
8641
viewport : ViewportSize = None ,
8642
+ screen : ViewportSize = None ,
8556
8643
no_viewport : bool = None ,
8557
8644
ignore_https_errors : bool = None ,
8558
8645
java_script_enabled : bool = None ,
@@ -8595,6 +8682,9 @@ async def new_context(
8595
8682
----------
8596
8683
viewport : Union[{width: int, height: int}, NoneType]
8597
8684
Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `no_viewport` disables the fixed viewport.
8685
+ screen : Union[{width: int, height: int}, NoneType]
8686
+ Emulates consistent window screen size available inside web page via `window.screen`. Is only used when the `viewport`
8687
+ is set.
8598
8688
no_viewport : Union[bool, NoneType]
8599
8689
Does not enforce fixed viewport, allows resizing window in the headed mode.
8600
8690
ignore_https_errors : Union[bool, NoneType]
@@ -8666,6 +8756,7 @@ async def new_context(
8666
8756
"browser.new_context" ,
8667
8757
self ._impl_obj .new_context (
8668
8758
viewport = viewport ,
8759
+ screen = screen ,
8669
8760
noViewport = no_viewport ,
8670
8761
ignoreHTTPSErrors = ignore_https_errors ,
8671
8762
javaScriptEnabled = java_script_enabled ,
@@ -8698,6 +8789,7 @@ async def new_page(
8698
8789
self ,
8699
8790
* ,
8700
8791
viewport : ViewportSize = None ,
8792
+ screen : ViewportSize = None ,
8701
8793
no_viewport : bool = None ,
8702
8794
ignore_https_errors : bool = None ,
8703
8795
java_script_enabled : bool = None ,
@@ -8735,6 +8827,9 @@ async def new_page(
8735
8827
----------
8736
8828
viewport : Union[{width: int, height: int}, NoneType]
8737
8829
Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `no_viewport` disables the fixed viewport.
8830
+ screen : Union[{width: int, height: int}, NoneType]
8831
+ Emulates consistent window screen size available inside web page via `window.screen`. Is only used when the `viewport`
8832
+ is set.
8738
8833
no_viewport : Union[bool, NoneType]
8739
8834
Does not enforce fixed viewport, allows resizing window in the headed mode.
8740
8835
ignore_https_errors : Union[bool, NoneType]
@@ -8806,6 +8901,7 @@ async def new_page(
8806
8901
"browser.new_page" ,
8807
8902
self ._impl_obj .new_page (
8808
8903
viewport = viewport ,
8904
+ screen = screen ,
8809
8905
noViewport = no_viewport ,
8810
8906
ignoreHTTPSErrors = ignore_https_errors ,
8811
8907
javaScriptEnabled = java_script_enabled ,
@@ -8947,7 +9043,8 @@ async def launch(
8947
9043
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox
8948
9044
or WebKit, use at your own risk.
8949
9045
channel : Union["chrome", "chrome-beta", "chrome-canary", "chrome-dev", "msedge", "msedge-beta", "msedge-canary", "msedge-dev", NoneType]
8950
- Browser distribution channel.
9046
+ Browser distribution channel. Read more about using
9047
+ [Google Chrome and Microsoft Edge](./browsers#google-chrome--microsoft-edge).
8951
9048
args : Union[List[str], NoneType]
8952
9049
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
8953
9050
[here](http://peter.sh/experiments/chromium-command-line-switches/).
@@ -9043,6 +9140,7 @@ async def launch_persistent_context(
9043
9140
downloads_path : typing .Union [str , pathlib .Path ] = None ,
9044
9141
slow_mo : float = None ,
9045
9142
viewport : ViewportSize = None ,
9143
+ screen : ViewportSize = None ,
9046
9144
no_viewport : bool = None ,
9047
9145
ignore_https_errors : bool = None ,
9048
9146
java_script_enabled : bool = None ,
@@ -9121,6 +9219,9 @@ async def launch_persistent_context(
9121
9219
Defaults to 0.
9122
9220
viewport : Union[{width: int, height: int}, NoneType]
9123
9221
Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. `no_viewport` disables the fixed viewport.
9222
+ screen : Union[{width: int, height: int}, NoneType]
9223
+ Emulates consistent window screen size available inside web page via `window.screen`. Is only used when the `viewport`
9224
+ is set.
9124
9225
no_viewport : Union[bool, NoneType]
9125
9226
Does not enforce fixed viewport, allows resizing window in the headed mode.
9126
9227
ignore_https_errors : Union[bool, NoneType]
@@ -9201,6 +9302,7 @@ async def launch_persistent_context(
9201
9302
downloadsPath = downloads_path ,
9202
9303
slowMo = slow_mo ,
9203
9304
viewport = viewport ,
9305
+ screen = screen ,
9204
9306
noViewport = no_viewport ,
9205
9307
ignoreHTTPSErrors = ignore_https_errors ,
9206
9308
javaScriptEnabled = java_script_enabled ,
0 commit comments