Skip to content

Commit ea66054

Browse files
authored
feat(roll): toll to the ToT 1617207797000 (#606)
1 parent 140ad1b commit ea66054

File tree

10 files changed

+393
-37
lines changed

10 files changed

+393
-37
lines changed

playwright/_impl/_browser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def is_connected(self) -> bool:
6969
async def new_context(
7070
self,
7171
viewport: ViewportSize = None,
72+
screen: ViewportSize = None,
7273
noViewport: bool = None,
7374
ignoreHTTPSErrors: bool = None,
7475
javaScriptEnabled: bool = None,
@@ -107,6 +108,7 @@ async def new_context(
107108
async def new_page(
108109
self,
109110
viewport: ViewportSize = None,
111+
screen: ViewportSize = None,
110112
noViewport: bool = None,
111113
ignoreHTTPSErrors: bool = None,
112114
javaScriptEnabled: bool = None,

playwright/_impl/_browser_type.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ async def launch_persistent_context(
9696
downloadsPath: Union[str, Path] = None,
9797
slowMo: float = None,
9898
viewport: ViewportSize = None,
99+
screen: ViewportSize = None,
99100
noViewport: bool = None,
100101
ignoreHTTPSErrors: bool = None,
101102
javaScriptEnabled: bool = None,

playwright/_impl/_frame.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ async def continuation() -> Optional[Response]:
181181

182182
return EventContextManagerImpl(asyncio.create_task(continuation()))
183183

184+
async def wait_for_url(
185+
self,
186+
url: URLMatch,
187+
wait_until: DocumentLoadState = None,
188+
timeout: float = None,
189+
) -> None:
190+
matcher = URLMatcher(url)
191+
if matcher.matches(self.url):
192+
await self.wait_for_load_state(state=wait_until, timeout=timeout)
193+
return
194+
async with self.expect_navigation(
195+
url=url, wait_until=wait_until, timeout=timeout
196+
):
197+
pass
198+
184199
async def wait_for_load_state(
185200
self, state: DocumentLoadState = None, timeout: float = None
186201
) -> None:

playwright/_impl/_page.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,14 @@ async def wait_for_load_state(
477477
) -> None:
478478
return await self._main_frame.wait_for_load_state(**locals_to_params(locals()))
479479

480+
async def wait_for_url(
481+
self,
482+
url: URLMatch,
483+
wait_until: DocumentLoadState = None,
484+
timeout: float = None,
485+
) -> None:
486+
return await self._main_frame.wait_for_url(**locals_to_params(locals()))
487+
480488
async def wait_for_event(
481489
self, event: str, predicate: Callable = None, timeout: float = None
482490
) -> Any:

playwright/async_api/_generated.py

Lines changed: 118 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ async def press(self, key: str, *, delay: float = None) -> NoneType:
819819
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
820820
texts.
821821
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
823823
modifier, modifier is pressed and being held while the subsequent key is being pressed.
824824
825825
```py
@@ -1390,8 +1390,8 @@ async def dispatch_event(
13901390
) -> NoneType:
13911391
"""ElementHandle.dispatch_event
13921392
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
13951395
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
13961396
13971397
```py
@@ -1948,7 +1948,7 @@ async def press(
19481948
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
19491949
texts.
19501950
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
19521952
modifier, modifier is pressed and being held while the subsequent key is being pressed.
19531953
19541954
Parameters
@@ -2709,6 +2709,47 @@ def expect_navigation(
27092709
).future
27102710
)
27112711

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+
27122753
async def wait_for_load_state(
27132754
self,
27142755
state: Literal["domcontentloaded", "load", "networkidle"] = None,
@@ -3169,8 +3210,8 @@ async def dispatch_event(
31693210
) -> NoneType:
31703211
"""Frame.dispatch_event
31713212
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
31743215
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
31753216
31763217
```py
@@ -4089,7 +4130,7 @@ async def press(
40894130
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
40904131
texts.
40914132
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
40934134
modifier, modifier is pressed and being held while the subsequent key is being pressed.
40944135
40954136
Parameters
@@ -4894,6 +4935,7 @@ def set_default_navigation_timeout(self, timeout: float) -> NoneType:
48944935
- `page.reload()`
48954936
- `page.set_content()`
48964937
- `page.expect_navigation()`
4938+
- `page.wait_for_url()`
48974939
48984940
> NOTE: `page.set_default_navigation_timeout()` takes priority over `page.set_default_timeout()`,
48994941
`browser_context.set_default_timeout()` and `browser_context.set_default_navigation_timeout()`.
@@ -5210,8 +5252,8 @@ async def dispatch_event(
52105252
) -> NoneType:
52115253
"""Page.dispatch_event
52125254
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
52155257
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).
52165258
52175259
```py
@@ -5904,6 +5946,49 @@ async def wait_for_load_state(
59045946
)
59055947
)
59065948

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+
59075992
async def wait_for_event(
59085993
self, event: str, predicate: typing.Callable = None, *, timeout: float = None
59095994
) -> typing.Any:
@@ -6163,7 +6248,7 @@ async def route(
61636248
61646249
> NOTE: The handler will only be called for the first url if the response is a redirect.
61656250
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:
61676252
61686253
```py
61696254
page = await browser.new_page()
@@ -6184,6 +6269,8 @@ async def route(
61846269
Page routes take precedence over browser context routes (set up with `browser_context.route()`) when request
61856270
matches both handlers.
61866271
6272+
To remove a route with its handler you can use `page.unroute()`.
6273+
61876274
> NOTE: Enabling routing disables http cache.
61886275
61896276
Parameters
@@ -6247,9 +6334,6 @@ async def screenshot(
62476334
62486335
Returns the buffer with the captured screenshot.
62496336
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-
62536337
Parameters
62546338
----------
62556339
timeout : Union[float, NoneType]
@@ -7001,7 +7085,7 @@ async def press(
70017085
If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different respective
70027086
texts.
70037087
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
70057089
modifier, modifier is pressed and being held while the subsequent key is being pressed.
70067090
70077091
```py
@@ -8190,7 +8274,7 @@ async def route(
81908274
Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
81918275
is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
81928276
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:
81948278
81958279
```py
81968280
context = await browser.new_context()
@@ -8214,6 +8298,8 @@ async def route(
82148298
Page routes (set up with `page.route()`) take precedence over browser context routes when request matches both
82158299
handlers.
82168300
8301+
To remove a route with its handler you can use `browser_context.unroute()`.
8302+
82178303
> NOTE: Enabling routing disables http cache.
82188304
82198305
Parameters
@@ -8553,6 +8639,7 @@ async def new_context(
85538639
self,
85548640
*,
85558641
viewport: ViewportSize = None,
8642+
screen: ViewportSize = None,
85568643
no_viewport: bool = None,
85578644
ignore_https_errors: bool = None,
85588645
java_script_enabled: bool = None,
@@ -8595,6 +8682,9 @@ async def new_context(
85958682
----------
85968683
viewport : Union[{width: int, height: int}, NoneType]
85978684
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.
85988688
no_viewport : Union[bool, NoneType]
85998689
Does not enforce fixed viewport, allows resizing window in the headed mode.
86008690
ignore_https_errors : Union[bool, NoneType]
@@ -8666,6 +8756,7 @@ async def new_context(
86668756
"browser.new_context",
86678757
self._impl_obj.new_context(
86688758
viewport=viewport,
8759+
screen=screen,
86698760
noViewport=no_viewport,
86708761
ignoreHTTPSErrors=ignore_https_errors,
86718762
javaScriptEnabled=java_script_enabled,
@@ -8698,6 +8789,7 @@ async def new_page(
86988789
self,
86998790
*,
87008791
viewport: ViewportSize = None,
8792+
screen: ViewportSize = None,
87018793
no_viewport: bool = None,
87028794
ignore_https_errors: bool = None,
87038795
java_script_enabled: bool = None,
@@ -8735,6 +8827,9 @@ async def new_page(
87358827
----------
87368828
viewport : Union[{width: int, height: int}, NoneType]
87378829
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.
87388833
no_viewport : Union[bool, NoneType]
87398834
Does not enforce fixed viewport, allows resizing window in the headed mode.
87408835
ignore_https_errors : Union[bool, NoneType]
@@ -8806,6 +8901,7 @@ async def new_page(
88068901
"browser.new_page",
88078902
self._impl_obj.new_page(
88088903
viewport=viewport,
8904+
screen=screen,
88098905
noViewport=no_viewport,
88108906
ignoreHTTPSErrors=ignore_https_errors,
88118907
javaScriptEnabled=java_script_enabled,
@@ -8947,7 +9043,8 @@ async def launch(
89479043
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox
89489044
or WebKit, use at your own risk.
89499045
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).
89519048
args : Union[List[str], NoneType]
89529049
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
89539050
[here](http://peter.sh/experiments/chromium-command-line-switches/).
@@ -9043,6 +9140,7 @@ async def launch_persistent_context(
90439140
downloads_path: typing.Union[str, pathlib.Path] = None,
90449141
slow_mo: float = None,
90459142
viewport: ViewportSize = None,
9143+
screen: ViewportSize = None,
90469144
no_viewport: bool = None,
90479145
ignore_https_errors: bool = None,
90489146
java_script_enabled: bool = None,
@@ -9121,6 +9219,9 @@ async def launch_persistent_context(
91219219
Defaults to 0.
91229220
viewport : Union[{width: int, height: int}, NoneType]
91239221
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.
91249225
no_viewport : Union[bool, NoneType]
91259226
Does not enforce fixed viewport, allows resizing window in the headed mode.
91269227
ignore_https_errors : Union[bool, NoneType]
@@ -9201,6 +9302,7 @@ async def launch_persistent_context(
92019302
downloadsPath=downloads_path,
92029303
slowMo=slow_mo,
92039304
viewport=viewport,
9305+
screen=screen,
92049306
noViewport=no_viewport,
92059307
ignoreHTTPSErrors=ignore_https_errors,
92069308
javaScriptEnabled=java_script_enabled,

0 commit comments

Comments
 (0)