Skip to content

Commit f4ec7c6

Browse files
authored
feat(roll): roll Playwright to 1.12.0-next-1622480418000 (#728)
1 parent 2817a80 commit f4ec7c6

File tree

8 files changed

+164
-67
lines changed

8 files changed

+164
-67
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
88
| :--- | :---: | :---: | :---: |
99
| Chromium <!-- GEN:chromium-version -->92.0.4513.0<!-- GEN:stop --> ||||
1010
| WebKit <!-- GEN:webkit-version -->14.2<!-- GEN:stop --> ||||
11-
| Firefox <!-- GEN:firefox-version -->89.0b9<!-- GEN:stop --> ||||
11+
| Firefox <!-- GEN:firefox-version -->89.0b15<!-- GEN:stop --> ||||
1212

1313
Headless execution is supported for all browsers on all platforms.
1414

playwright/_impl/_browser_type.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from_nullable_channel,
3434
)
3535
from playwright._impl._helper import (
36-
BrowserChannel,
3736
ColorScheme,
3837
Env,
3938
ReducedMotion,
@@ -64,7 +63,7 @@ def executable_path(self) -> str:
6463
async def launch(
6564
self,
6665
executablePath: Union[str, Path] = None,
67-
channel: BrowserChannel = None,
66+
channel: str = None,
6867
args: List[str] = None,
6968
ignoreDefaultArgs: Union[bool, List[str]] = None,
7069
handleSIGINT: bool = None,
@@ -93,7 +92,7 @@ async def launch(
9392
async def launch_persistent_context(
9493
self,
9594
userDataDir: Union[str, Path],
96-
channel: BrowserChannel = None,
95+
channel: str = None,
9796
executablePath: Union[str, Path] = None,
9897
args: List[str] = None,
9998
ignoreDefaultArgs: Union[bool, List[str]] = None,

playwright/_impl/_helper.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,6 @@
5555
KeyboardModifier = Literal["Alt", "Control", "Meta", "Shift"]
5656
MouseButton = Literal["left", "middle", "right"]
5757

58-
BrowserChannel = Literal[
59-
"chrome",
60-
"chrome-beta",
61-
"chrome-canary",
62-
"chrome-dev",
63-
"msedge",
64-
"msedge-beta",
65-
"msedge-canary",
66-
"msedge-dev",
67-
]
68-
6958

7059
class ErrorPayload(TypedDict, total=False):
7160
message: str

playwright/_impl/_page.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878

7979
if TYPE_CHECKING: # pragma: no cover
8080
from playwright._impl._browser_context import BrowserContext
81+
from playwright._impl._network import WebSocket
8182

8283

8384
class Page(ChannelOwner):
@@ -826,6 +827,15 @@ def my_predicate(request: Request) -> bool:
826827
Page.Events.Request, predicate=my_predicate, timeout=timeout
827828
)
828829

830+
def expect_request_finished(
831+
self,
832+
predicate: Callable[["Request"], bool] = None,
833+
timeout: float = None,
834+
) -> EventContextManagerImpl[Request]:
835+
return self.expect_event(
836+
Page.Events.RequestFinished, predicate=predicate, timeout=timeout
837+
)
838+
829839
def expect_response(
830840
self,
831841
url_or_predicate: URLMatchResponse,
@@ -845,6 +855,13 @@ def my_predicate(response: Response) -> bool:
845855
Page.Events.Response, predicate=my_predicate, timeout=timeout
846856
)
847857

858+
def expect_websocket(
859+
self,
860+
predicate: Callable[["WebSocket"], bool] = None,
861+
timeout: float = None,
862+
) -> EventContextManagerImpl["WebSocket"]:
863+
return self.expect_event("websocket", predicate, timeout)
864+
848865
def expect_worker(
849866
self,
850867
predicate: Callable[["Worker"], bool] = None,

playwright/async_api/_generated.py

Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7749,7 +7749,7 @@ def expect_console_message(
77497749
77507750
Performs action and waits for a `ConsoleMessage` to be logged by in the page. If predicate is provided, it passes
77517751
`ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value. Will
7752-
throw an error if the page is closed before the console event is fired.
7752+
throw an error if the page is closed before the `page.on('console')` event is fired.
77537753
77547754
Parameters
77557755
----------
@@ -7960,6 +7960,37 @@ def expect_request(
79607960
).future
79617961
)
79627962

7963+
def expect_request_finished(
7964+
self,
7965+
predicate: typing.Optional[typing.Callable[["Request"], bool]] = None,
7966+
*,
7967+
timeout: float = None
7968+
) -> AsyncEventContextManager["Request"]:
7969+
"""Page.expect_request_finished
7970+
7971+
Performs action and waits for a `Request` to finish loading. If predicate is provided, it passes `Request` value into
7972+
the `predicate` function and waits for `predicate(request)` to return a truthy value. Will throw an error if the page is
7973+
closed before the `page.on('request_finished')` event is fired.
7974+
7975+
Parameters
7976+
----------
7977+
predicate : Union[Callable[[Request], bool], NoneType]
7978+
Receives the `Request` object and resolves to truthy value when the waiting should resolve.
7979+
timeout : Union[float, NoneType]
7980+
Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
7981+
value can be changed by using the `browser_context.set_default_timeout()`.
7982+
7983+
Returns
7984+
-------
7985+
EventContextManager[Request]
7986+
"""
7987+
7988+
return AsyncEventContextManager(
7989+
self._impl_obj.expect_request_finished(
7990+
predicate=self._wrap_handler(predicate), timeout=timeout
7991+
).future
7992+
)
7993+
79637994
def expect_response(
79647995
self,
79657996
url_or_predicate: typing.Union[
@@ -8004,6 +8035,37 @@ def expect_response(
80048035
).future
80058036
)
80068037

8038+
def expect_websocket(
8039+
self,
8040+
predicate: typing.Optional[typing.Callable[["WebSocket"], bool]] = None,
8041+
*,
8042+
timeout: float = None
8043+
) -> AsyncEventContextManager["WebSocket"]:
8044+
"""Page.expect_websocket
8045+
8046+
Performs action and waits for a new `WebSocket`. If predicate is provided, it passes `WebSocket` value into the
8047+
`predicate` function and waits for `predicate(webSocket)` to return a truthy value. Will throw an error if the page is
8048+
closed before the WebSocket event is fired.
8049+
8050+
Parameters
8051+
----------
8052+
predicate : Union[Callable[[WebSocket], bool], NoneType]
8053+
Receives the `WebSocket` object and resolves to truthy value when the waiting should resolve.
8054+
timeout : Union[float, NoneType]
8055+
Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
8056+
value can be changed by using the `browser_context.set_default_timeout()`.
8057+
8058+
Returns
8059+
-------
8060+
EventContextManager[WebSocket]
8061+
"""
8062+
8063+
return AsyncEventContextManager(
8064+
self._impl_obj.expect_websocket(
8065+
predicate=self._wrap_handler(predicate), timeout=timeout
8066+
).future
8067+
)
8068+
80078069
def expect_worker(
80088070
self,
80098071
predicate: typing.Optional[typing.Callable[["Worker"], bool]] = None,
@@ -9318,16 +9380,7 @@ async def launch(
93189380
self,
93199381
*,
93209382
executable_path: typing.Union[str, pathlib.Path] = None,
9321-
channel: Literal[
9322-
"chrome",
9323-
"chrome-beta",
9324-
"chrome-canary",
9325-
"chrome-dev",
9326-
"msedge",
9327-
"msedge-beta",
9328-
"msedge-canary",
9329-
"msedge-dev",
9330-
] = None,
9383+
channel: str = None,
93319384
args: typing.List[str] = None,
93329385
ignore_default_args: typing.Union[bool, typing.List[str]] = None,
93339386
handle_sigint: bool = None,
@@ -9379,8 +9432,9 @@ async def launch(
93799432
Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
93809433
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox
93819434
or WebKit, use at your own risk.
9382-
channel : Union["chrome", "chrome-beta", "chrome-canary", "chrome-dev", "msedge", "msedge-beta", "msedge-canary", "msedge-dev", NoneType]
9383-
Browser distribution channel. Read more about using
9435+
channel : Union[str, NoneType]
9436+
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
9437+
"msedge-beta", "msedge-dev", "msedge-canary". Read more about using
93849438
[Google Chrome and Microsoft Edge](./browsers.md#google-chrome--microsoft-edge).
93859439
args : Union[List[str], NoneType]
93869440
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
@@ -9456,16 +9510,7 @@ async def launch_persistent_context(
94569510
self,
94579511
user_data_dir: typing.Union[str, pathlib.Path],
94589512
*,
9459-
channel: Literal[
9460-
"chrome",
9461-
"chrome-beta",
9462-
"chrome-canary",
9463-
"chrome-dev",
9464-
"msedge",
9465-
"msedge-beta",
9466-
"msedge-canary",
9467-
"msedge-dev",
9468-
] = None,
9513+
channel: str = None,
94699514
executable_path: typing.Union[str, pathlib.Path] = None,
94709515
args: typing.List[str] = None,
94719516
ignore_default_args: typing.Union[bool, typing.List[str]] = None,
@@ -9520,8 +9565,9 @@ async def launch_persistent_context(
95209565
[Chromium](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md#introduction) and
95219566
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#User_Profile). Note that Chromium's user
95229567
data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`.
9523-
channel : Union["chrome", "chrome-beta", "chrome-canary", "chrome-dev", "msedge", "msedge-beta", "msedge-canary", "msedge-dev", NoneType]
9524-
Browser distribution channel. Read more about using
9568+
channel : Union[str, NoneType]
9569+
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
9570+
"msedge-beta", "msedge-dev", "msedge-canary". Read more about using
95259571
[Google Chrome and Microsoft Edge](./browsers.md#google-chrome--microsoft-edge).
95269572
executable_path : Union[pathlib.Path, str, NoneType]
95279573
Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is

playwright/sync_api/_generated.py

Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7703,7 +7703,7 @@ def expect_console_message(
77037703
77047704
Performs action and waits for a `ConsoleMessage` to be logged by in the page. If predicate is provided, it passes
77057705
`ConsoleMessage` value into the `predicate` function and waits for `predicate(message)` to return a truthy value. Will
7706-
throw an error if the page is closed before the console event is fired.
7706+
throw an error if the page is closed before the `page.on('console')` event is fired.
77077707
77087708
Parameters
77097709
----------
@@ -7914,6 +7914,37 @@ def expect_request(
79147914
).future,
79157915
)
79167916

7917+
def expect_request_finished(
7918+
self,
7919+
predicate: typing.Optional[typing.Callable[["Request"], bool]] = None,
7920+
*,
7921+
timeout: float = None
7922+
) -> EventContextManager["Request"]:
7923+
"""Page.expect_request_finished
7924+
7925+
Performs action and waits for a `Request` to finish loading. If predicate is provided, it passes `Request` value into
7926+
the `predicate` function and waits for `predicate(request)` to return a truthy value. Will throw an error if the page is
7927+
closed before the `page.on('request_finished')` event is fired.
7928+
7929+
Parameters
7930+
----------
7931+
predicate : Union[Callable[[Request], bool], NoneType]
7932+
Receives the `Request` object and resolves to truthy value when the waiting should resolve.
7933+
timeout : Union[float, NoneType]
7934+
Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
7935+
value can be changed by using the `browser_context.set_default_timeout()`.
7936+
7937+
Returns
7938+
-------
7939+
EventContextManager[Request]
7940+
"""
7941+
return EventContextManager(
7942+
self,
7943+
self._impl_obj.expect_request_finished(
7944+
predicate=self._wrap_handler(predicate), timeout=timeout
7945+
).future,
7946+
)
7947+
79177948
def expect_response(
79187949
self,
79197950
url_or_predicate: typing.Union[
@@ -7958,6 +7989,37 @@ def expect_response(
79587989
).future,
79597990
)
79607991

7992+
def expect_websocket(
7993+
self,
7994+
predicate: typing.Optional[typing.Callable[["WebSocket"], bool]] = None,
7995+
*,
7996+
timeout: float = None
7997+
) -> EventContextManager["WebSocket"]:
7998+
"""Page.expect_websocket
7999+
8000+
Performs action and waits for a new `WebSocket`. If predicate is provided, it passes `WebSocket` value into the
8001+
`predicate` function and waits for `predicate(webSocket)` to return a truthy value. Will throw an error if the page is
8002+
closed before the WebSocket event is fired.
8003+
8004+
Parameters
8005+
----------
8006+
predicate : Union[Callable[[WebSocket], bool], NoneType]
8007+
Receives the `WebSocket` object and resolves to truthy value when the waiting should resolve.
8008+
timeout : Union[float, NoneType]
8009+
Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
8010+
value can be changed by using the `browser_context.set_default_timeout()`.
8011+
8012+
Returns
8013+
-------
8014+
EventContextManager[WebSocket]
8015+
"""
8016+
return EventContextManager(
8017+
self,
8018+
self._impl_obj.expect_websocket(
8019+
predicate=self._wrap_handler(predicate), timeout=timeout
8020+
).future,
8021+
)
8022+
79618023
def expect_worker(
79628024
self,
79638025
predicate: typing.Optional[typing.Callable[["Worker"], bool]] = None,
@@ -9264,16 +9326,7 @@ def launch(
92649326
self,
92659327
*,
92669328
executable_path: typing.Union[str, pathlib.Path] = None,
9267-
channel: Literal[
9268-
"chrome",
9269-
"chrome-beta",
9270-
"chrome-canary",
9271-
"chrome-dev",
9272-
"msedge",
9273-
"msedge-beta",
9274-
"msedge-canary",
9275-
"msedge-dev",
9276-
] = None,
9329+
channel: str = None,
92779330
args: typing.List[str] = None,
92789331
ignore_default_args: typing.Union[bool, typing.List[str]] = None,
92799332
handle_sigint: bool = None,
@@ -9325,8 +9378,9 @@ def launch(
93259378
Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is
93269379
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox
93279380
or WebKit, use at your own risk.
9328-
channel : Union["chrome", "chrome-beta", "chrome-canary", "chrome-dev", "msedge", "msedge-beta", "msedge-canary", "msedge-dev", NoneType]
9329-
Browser distribution channel. Read more about using
9381+
channel : Union[str, NoneType]
9382+
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
9383+
"msedge-beta", "msedge-dev", "msedge-canary". Read more about using
93309384
[Google Chrome and Microsoft Edge](./browsers.md#google-chrome--microsoft-edge).
93319385
args : Union[List[str], NoneType]
93329386
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
@@ -9402,16 +9456,7 @@ def launch_persistent_context(
94029456
self,
94039457
user_data_dir: typing.Union[str, pathlib.Path],
94049458
*,
9405-
channel: Literal[
9406-
"chrome",
9407-
"chrome-beta",
9408-
"chrome-canary",
9409-
"chrome-dev",
9410-
"msedge",
9411-
"msedge-beta",
9412-
"msedge-canary",
9413-
"msedge-dev",
9414-
] = None,
9459+
channel: str = None,
94159460
executable_path: typing.Union[str, pathlib.Path] = None,
94169461
args: typing.List[str] = None,
94179462
ignore_default_args: typing.Union[bool, typing.List[str]] = None,
@@ -9466,8 +9511,9 @@ def launch_persistent_context(
94669511
[Chromium](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md#introduction) and
94679512
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#User_Profile). Note that Chromium's user
94689513
data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`.
9469-
channel : Union["chrome", "chrome-beta", "chrome-canary", "chrome-dev", "msedge", "msedge-beta", "msedge-canary", "msedge-dev", NoneType]
9470-
Browser distribution channel. Read more about using
9514+
channel : Union[str, NoneType]
9515+
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
9516+
"msedge-beta", "msedge-dev", "msedge-canary". Read more about using
94719517
[Google Chrome and Microsoft Edge](./browsers.md#google-chrome--microsoft-edge).
94729518
executable_path : Union[pathlib.Path, str, NoneType]
94739519
Path to a browser executable to run instead of the bundled one. If `executablePath` is a relative path, then it is

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
InWheel = None
2929
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand
3030

31-
driver_version = "1.12.0-next-1621812078000"
31+
driver_version = "1.12.0-next-1622480418000"
3232

3333

3434
def extractall(zip: zipfile.ZipFile, path: str) -> None:

tests/async/test_websocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def test_should_work(page, ws_server):
3434

3535

3636
async def test_should_emit_close_events(page, ws_server):
37-
async with page.expect_event("websocket") as ws_info:
37+
async with page.expect_websocket() as ws_info:
3838
await page.evaluate(
3939
"""port => {
4040
let cb;

0 commit comments

Comments
 (0)