@@ -92,6 +92,8 @@ def resource_type(self) -> str:
92
92
following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
93
93
`websocket`, `manifest`, `other`.
94
94
95
+ > NOTE: The resource types are available as constants in [ResourceTypes].
96
+
95
97
Returns
96
98
-------
97
99
str
@@ -2837,7 +2839,7 @@ async def evaluate_handle(
2837
2839
Returns the return value of `expression` as a `JSHandle`.
2838
2840
2839
2841
The only difference between `frame.evaluate()` and `frame.evaluate_handle()` is that
2840
- [method: Frame.evaluateHandle`] returns `JSHandle`.
2842
+ `frame.evaluate_handle()` returns `JSHandle`.
2841
2843
2842
2844
If the function, passed to the `frame.evaluate_handle()`, returns a [Promise], then
2843
2845
`frame.evaluate_handle()` would wait for the promise to resolve and return its value.
@@ -4359,7 +4361,7 @@ async def evaluate(self, expression: str, arg: typing.Any = None) -> typing.Any:
4359
4361
wait for the promise to resolve and return its value.
4360
4362
4361
4363
If the function passed to the `worker.evaluate()` returns a non-[Serializable] value, then
4362
- `worker.evaluate()` returns `undefined`. Playwright also supports transferring some additional values that are
4364
+ `worker.evaluate()` returns `undefined`. Playwright also supports transferring some additional values that are
4363
4365
not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
4364
4366
4365
4367
Parameters
@@ -4629,7 +4631,7 @@ def suggested_filename(self) -> str:
4629
4631
async def delete (self ) -> NoneType :
4630
4632
"""Download.delete
4631
4633
4632
- Deletes the downloaded file.
4634
+ Deletes the downloaded file. Will wait for the download to finish if necessary.
4633
4635
"""
4634
4636
4635
4637
return mapping .from_maybe_impl (
@@ -4639,7 +4641,7 @@ async def delete(self) -> NoneType:
4639
4641
async def failure (self ) -> typing .Optional [str ]:
4640
4642
"""Download.failure
4641
4643
4642
- Returns download error if any.
4644
+ Returns download error if any. Will wait for the download to finish if necessary.
4643
4645
4644
4646
Returns
4645
4647
-------
@@ -4653,7 +4655,8 @@ async def failure(self) -> typing.Optional[str]:
4653
4655
async def path (self ) -> typing .Optional [pathlib .Path ]:
4654
4656
"""Download.path
4655
4657
4656
- Returns path to the downloaded file in case of successful download.
4658
+ Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if
4659
+ necessary.
4657
4660
4658
4661
Returns
4659
4662
-------
@@ -4667,7 +4670,7 @@ async def path(self) -> typing.Optional[pathlib.Path]:
4667
4670
async def save_as (self , path : typing .Union [str , pathlib .Path ]) -> NoneType :
4668
4671
"""Download.save_as
4669
4672
4670
- Saves the download to a user-specified path.
4673
+ Saves the download to a user-specified path. It is safe to call this method while the download is still in progress.
4671
4674
4672
4675
Parameters
4673
4676
----------
@@ -7666,9 +7669,16 @@ def expect_response(
7666
7669
Returns the matched response.
7667
7670
7668
7671
```py
7669
- first_response = await page.wait_for_response(\" https://example.com/resource\" )
7670
- final_response = await page.wait_for_response(lambda response: response.url == \" https://example.com\" and response.status === 200)
7671
- return final_response.ok
7672
+ async with page.expect_response(\" https://example.com/resource\" ) as response_info:
7673
+ await page.click(\" input\" )
7674
+ response = response_info.value
7675
+ return response.ok
7676
+
7677
+ # or with a lambda
7678
+ async with page.expect_response(lambda response: response.url == \" https://example.com\" and response.status === 200) as response_info:
7679
+ await page.click(\" input\" )
7680
+ response = response_info.value
7681
+ return response.ok
7672
7682
```
7673
7683
7674
7684
Parameters
@@ -8623,7 +8633,7 @@ async def new_context(
8623
8633
Specifies if viewport supports touch events. Defaults to false.
8624
8634
color_scheme : Union["dark", "light", "no-preference", NoneType]
8625
8635
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
8626
- `page.emulate_media()` for more details. Defaults to '` light`' .
8636
+ `page.emulate_media()` for more details. Defaults to `' light'` .
8627
8637
accept_downloads : Union[bool, NoneType]
8628
8638
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
8629
8639
proxy : Union[{server: str, bypass: Union[str, NoneType], username: Union[str, NoneType], password: Union[str, NoneType]}, NoneType]
@@ -8760,7 +8770,7 @@ async def new_page(
8760
8770
Specifies if viewport supports touch events. Defaults to false.
8761
8771
color_scheme : Union["dark", "light", "no-preference", NoneType]
8762
8772
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
8763
- `page.emulate_media()` for more details. Defaults to '` light`' .
8773
+ `page.emulate_media()` for more details. Defaults to `' light'` .
8764
8774
accept_downloads : Union[bool, NoneType]
8765
8775
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
8766
8776
proxy : Union[{server: str, bypass: Union[str, NoneType], username: Union[str, NoneType], password: Union[str, NoneType]}, NoneType]
@@ -8872,6 +8882,7 @@ async def launch(
8872
8882
self ,
8873
8883
* ,
8874
8884
executable_path : typing .Union [str , pathlib .Path ] = None ,
8885
+ channel : str = None ,
8875
8886
args : typing .List [str ] = None ,
8876
8887
ignore_default_args : typing .Union [bool , typing .List [str ]] = None ,
8877
8888
handle_sigint : bool = None ,
@@ -8922,6 +8933,16 @@ async def launch(
8922
8933
Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
8923
8934
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox
8924
8935
or WebKit, use at your own risk.
8936
+ channel : Union[str, NoneType]
8937
+ Chromium distribution channel, one of
8938
+ - chrome
8939
+ - chrome-beta
8940
+ - chrome-dev
8941
+ - chrome-canary
8942
+ - msedge
8943
+ - msedge-beta
8944
+ - msedge-dev
8945
+ - msedge-canary
8925
8946
args : Union[List[str], NoneType]
8926
8947
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
8927
8948
[here](http://peter.sh/experiments/chromium-command-line-switches/).
@@ -8970,6 +8991,7 @@ async def launch(
8970
8991
"browser_type.launch" ,
8971
8992
self ._impl_obj .launch (
8972
8993
executablePath = executable_path ,
8994
+ channel = channel ,
8973
8995
args = args ,
8974
8996
ignoreDefaultArgs = ignore_default_args ,
8975
8997
handleSIGINT = handle_sigint ,
@@ -8992,6 +9014,7 @@ async def launch_persistent_context(
8992
9014
self ,
8993
9015
user_data_dir : typing .Union [str , pathlib .Path ],
8994
9016
* ,
9017
+ channel : str = None ,
8995
9018
executable_path : typing .Union [str , pathlib .Path ] = None ,
8996
9019
args : typing .List [str ] = None ,
8997
9020
ignore_default_args : typing .Union [bool , typing .List [str ]] = None ,
@@ -9043,6 +9066,16 @@ async def launch_persistent_context(
9043
9066
[Chromium](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md#introduction) and
9044
9067
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#User_Profile). Note that Chromium's user
9045
9068
data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`.
9069
+ channel : Union[str, NoneType]
9070
+ Chromium distribution channel, one of
9071
+ - chrome
9072
+ - chrome-beta
9073
+ - chrome-dev
9074
+ - chrome-canary
9075
+ - msedge
9076
+ - msedge-beta
9077
+ - msedge-dev
9078
+ - msedge-canary
9046
9079
executable_path : Union[pathlib.Path, str, NoneType]
9047
9080
Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
9048
9081
resolved relative to the current working directory. **BEWARE**: Playwright is only guaranteed to work with the bundled
@@ -9118,7 +9151,7 @@ async def launch_persistent_context(
9118
9151
Specifies if viewport supports touch events. Defaults to false.
9119
9152
color_scheme : Union["dark", "light", "no-preference", NoneType]
9120
9153
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
9121
- `page.emulate_media()` for more details. Defaults to '` light`' .
9154
+ `page.emulate_media()` for more details. Defaults to `' light'` .
9122
9155
accept_downloads : Union[bool, NoneType]
9123
9156
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
9124
9157
chromium_sandbox : Union[bool, NoneType]
@@ -9144,6 +9177,7 @@ async def launch_persistent_context(
9144
9177
"browser_type.launch_persistent_context" ,
9145
9178
self ._impl_obj .launch_persistent_context (
9146
9179
userDataDir = user_data_dir ,
9180
+ channel = channel ,
9147
9181
executablePath = executable_path ,
9148
9182
args = args ,
9149
9183
ignoreDefaultArgs = ignore_default_args ,
0 commit comments