Skip to content

Commit ac3211e

Browse files
committed
chore(roll): roll to Playwright 1.41.0-alpha-1702670966000 part 1
1 parent 7f35a42 commit ac3211e

17 files changed

+797
-297
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
44

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->120.0.6099.28<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->121.0.6167.16<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->119.0<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->120.0.1<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

playwright/_impl/_browser_context.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ async def _on_route(self, route: Route) -> None:
223223
for route_handler in route_handlers:
224224
if not route_handler.matches(route.request.url):
225225
continue
226+
if route_handler not in self._routes:
227+
continue
226228
if route_handler.will_expire:
227229
self._routes.remove(route_handler)
228230
try:
@@ -369,6 +371,11 @@ async def unroute(
369371
)
370372
await self._update_interception_patterns()
371373

374+
async def unroute_all(
375+
self, behavior: Literal["default", "ignoreErrors", "wait"] = None
376+
) -> None:
377+
pass
378+
372379
async def _record_into_har(
373380
self,
374381
har: Union[Path, str],

playwright/_impl/_element_handle.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ async def screenshot(
298298
scale: Literal["css", "device"] = None,
299299
mask: Sequence["Locator"] = None,
300300
maskColor: str = None,
301+
style: str = None,
301302
) -> bytes:
302303
params = locals_to_params(locals())
303304
if "path" in params:

playwright/_impl/_locator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ async def screenshot(
523523
scale: Literal["css", "device"] = None,
524524
mask: Sequence["Locator"] = None,
525525
maskColor: str = None,
526+
style: str = None,
526527
) -> bytes:
527528
params = locals_to_params(locals())
528529
return await self._with_element(

playwright/_impl/_page.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ async def _on_route(self, route: Route) -> None:
240240
for route_handler in route_handlers:
241241
if not route_handler.matches(route.request.url):
242242
continue
243+
if route_handler not in self._routes:
244+
continue
243245
if route_handler.will_expire:
244246
self._routes.remove(route_handler)
245247
try:
@@ -593,6 +595,11 @@ async def unroute(
593595
)
594596
await self._update_interception_patterns()
595597

598+
async def unroute_all(
599+
self, behavior: Literal["default", "ignoreErrors", "wait"] = None
600+
) -> None:
601+
pass
602+
596603
async def route_from_har(
597604
self,
598605
har: Union[Path, str],
@@ -639,6 +646,7 @@ async def screenshot(
639646
scale: Literal["css", "device"] = None,
640647
mask: Sequence["Locator"] = None,
641648
maskColor: str = None,
649+
style: str = None,
642650
) -> bytes:
643651
params = locals_to_params(locals())
644652
if "path" in params:

playwright/_impl/_set_input_files_helpers.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ async def convert_input_files(
6262
assert isinstance(item, (str, Path))
6363
last_modified_ms = int(os.path.getmtime(item) * 1000)
6464
stream: WritableStream = from_channel(
65-
await context._channel.send(
66-
"createTempFile",
67-
{
68-
"name": os.path.basename(item),
69-
"lastModifiedMs": last_modified_ms,
70-
},
65+
await context._connection.wrap_api_call(
66+
lambda: context._channel.send(
67+
"createTempFile",
68+
{
69+
"name": os.path.basename(cast(str, item)),
70+
"lastModifiedMs": last_modified_ms,
71+
},
72+
)
7173
)
7274
)
7375
await stream.copy(item)

playwright/async_api/_generated.py

Lines changed: 110 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,7 +2769,8 @@ async def screenshot(
27692769
caret: typing.Optional[Literal["hide", "initial"]] = None,
27702770
scale: typing.Optional[Literal["css", "device"]] = None,
27712771
mask: typing.Optional[typing.Sequence["Locator"]] = None,
2772-
mask_color: typing.Optional[str] = None
2772+
mask_color: typing.Optional[str] = None,
2773+
style: typing.Optional[str] = None
27732774
) -> bytes:
27742775
"""ElementHandle.screenshot
27752776

@@ -2820,6 +2821,10 @@ async def screenshot(
28202821
mask_color : Union[str, None]
28212822
Specify the color of the overlay box for masked elements, in
28222823
[CSS color format](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Default color is pink `#FF00FF`.
2824+
style : Union[str, None]
2825+
Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make
2826+
elements invisible or change their properties to help you creating repeatable screenshots. This stylesheet pierces
2827+
the Shadow DOM and applies to the inner frames.
28232828

28242829
Returns
28252830
-------
@@ -2838,6 +2843,7 @@ async def screenshot(
28382843
scale=scale,
28392844
mask=mapping.to_impl(mask),
28402845
maskColor=mask_color,
2846+
style=style,
28412847
)
28422848
)
28432849

@@ -4709,8 +4715,13 @@ def locator(
47094715
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
47104716
When passed a [string], matching is case-insensitive and searches for a substring.
47114717
has : Union[Locator, None]
4712-
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
4713-
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
4718+
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
4719+
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
4720+
4721+
Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
4722+
the document root. For example, you can find `content` that has `div` in
4723+
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
4724+
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.
47144725

47154726
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
47164727
has_not : Union[Locator, None]
@@ -6245,8 +6256,13 @@ def locator(
62456256
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
62466257
When passed a [string], matching is case-insensitive and searches for a substring.
62476258
has : Union[Locator, None]
6248-
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
6249-
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
6259+
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
6260+
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
6261+
6262+
Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
6263+
the document root. For example, you can find `content` that has `div` in
6264+
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
6265+
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.
62506266

62516267
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
62526268
has_not : Union[Locator, None]
@@ -9856,6 +9872,30 @@ async def unroute(
98569872
)
98579873
)
98589874

9875+
async def unroute_all(
9876+
self,
9877+
*,
9878+
behavior: typing.Optional[Literal["default", "ignoreErrors", "wait"]] = None
9879+
) -> None:
9880+
"""Page.unroute_all
9881+
9882+
Removes all routes created with `page.route()` and `page.route_from_har()`.
9883+
9884+
Parameters
9885+
----------
9886+
behavior : Union["default", "ignoreErrors", "wait", None]
9887+
Specifies wether to wait for already running handlers and what to do if they throw errors:
9888+
- `'default'` - do not wait for current handler calls (if any) to finish, if unrouted handler throws, it may
9889+
result in unhandled error
9890+
- `'wait'` - wait for current handler calls (if any) to finish
9891+
- `'ignoreErrors'` - do not wait for current handler calls (if any) to finish, all errors thrown by the handlers
9892+
after unrouting are silently caught
9893+
"""
9894+
9895+
return mapping.from_maybe_impl(
9896+
await self._impl_obj.unroute_all(behavior=behavior)
9897+
)
9898+
98599899
async def route_from_har(
98609900
self,
98619901
har: typing.Union[pathlib.Path, str],
@@ -9924,7 +9964,8 @@ async def screenshot(
99249964
caret: typing.Optional[Literal["hide", "initial"]] = None,
99259965
scale: typing.Optional[Literal["css", "device"]] = None,
99269966
mask: typing.Optional[typing.Sequence["Locator"]] = None,
9927-
mask_color: typing.Optional[str] = None
9967+
mask_color: typing.Optional[str] = None,
9968+
style: typing.Optional[str] = None
99289969
) -> bytes:
99299970
"""Page.screenshot
99309971

@@ -9973,6 +10014,10 @@ async def screenshot(
997310014
mask_color : Union[str, None]
997410015
Specify the color of the overlay box for masked elements, in
997510016
[CSS color format](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Default color is pink `#FF00FF`.
10017+
style : Union[str, None]
10018+
Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make
10019+
elements invisible or change their properties to help you creating repeatable screenshots. This stylesheet pierces
10020+
the Shadow DOM and applies to the inner frames.
997610021

997710022
Returns
997810023
-------
@@ -9993,6 +10038,7 @@ async def screenshot(
999310038
scale=scale,
999410039
mask=mapping.to_impl(mask),
999510040
maskColor=mask_color,
10041+
style=style,
999610042
)
999710043
)
999810044

@@ -10362,8 +10408,13 @@ def locator(
1036210408
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
1036310409
When passed a [string], matching is case-insensitive and searches for a substring.
1036410410
has : Union[Locator, None]
10365-
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
10366-
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
10411+
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
10412+
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
10413+
10414+
Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
10415+
the document root. For example, you can find `content` that has `div` in
10416+
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
10417+
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.
1036710418

1036810419
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
1036910420
has_not : Union[Locator, None]
@@ -13640,6 +13691,30 @@ async def unroute(
1364013691
)
1364113692
)
1364213693

13694+
async def unroute_all(
13695+
self,
13696+
*,
13697+
behavior: typing.Optional[Literal["default", "ignoreErrors", "wait"]] = None
13698+
) -> None:
13699+
"""BrowserContext.unroute_all
13700+
13701+
Removes all routes created with `browser_context.route()` and `browser_context.route_from_har()`.
13702+
13703+
Parameters
13704+
----------
13705+
behavior : Union["default", "ignoreErrors", "wait", None]
13706+
Specifies wether to wait for already running handlers and what to do if they throw errors:
13707+
- `'default'` - do not wait for current handler calls (if any) to finish, if unrouted handler throws, it may
13708+
result in unhandled error
13709+
- `'wait'` - wait for current handler calls (if any) to finish
13710+
- `'ignoreErrors'` - do not wait for current handler calls (if any) to finish, all errors thrown by the handlers
13711+
after unrouting are silently caught
13712+
"""
13713+
13714+
return mapping.from_maybe_impl(
13715+
await self._impl_obj.unroute_all(behavior=behavior)
13716+
)
13717+
1364313718
async def route_from_har(
1364413719
self,
1364513720
har: typing.Union[pathlib.Path, str],
@@ -14690,8 +14765,10 @@ async def launch(
1469014765
"msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using
1469114766
[Google Chrome and Microsoft Edge](../browsers.md#google-chrome--microsoft-edge).
1469214767
args : Union[Sequence[str], None]
14768+
**NOTE** Use custom browser args at your own risk, as some of them may break Playwright functionality.
14769+
1469314770
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
14694-
[here](http://peter.sh/experiments/chromium-command-line-switches/).
14771+
[here](https://peter.sh/experiments/chromium-command-line-switches/).
1469514772
ignore_default_args : Union[Sequence[str], bool, None]
1469614773
If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is
1469714774
given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`.
@@ -14845,8 +14922,10 @@ async def launch_persistent_context(
1484514922
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium,
1484614923
Firefox or WebKit, use at your own risk.
1484714924
args : Union[Sequence[str], None]
14925+
**NOTE** Use custom browser args at your own risk, as some of them may break Playwright functionality.
14926+
1484814927
Additional arguments to pass to the browser instance. The list of Chromium flags can be found
14849-
[here](http://peter.sh/experiments/chromium-command-line-switches/).
14928+
[here](https://peter.sh/experiments/chromium-command-line-switches/).
1485014929
ignore_default_args : Union[Sequence[str], bool, None]
1485114930
If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is
1485214931
given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`.
@@ -16144,8 +16223,13 @@ def locator(
1614416223
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
1614516224
When passed a [string], matching is case-insensitive and searches for a substring.
1614616225
has : Union[Locator, None]
16147-
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
16148-
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
16226+
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
16227+
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
16228+
16229+
Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
16230+
the document root. For example, you can find `content` that has `div` in
16231+
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
16232+
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.
1614916233

1615016234
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
1615116235
has_not : Union[Locator, None]
@@ -16806,8 +16890,13 @@ def filter(
1680616890
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
1680716891
When passed a [string], matching is case-insensitive and searches for a substring.
1680816892
has : Union[Locator, None]
16809-
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
16810-
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
16893+
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
16894+
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
16895+
16896+
Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
16897+
the document root. For example, you can find `content` that has `div` in
16898+
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
16899+
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.
1681116900

1681216901
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
1681316902
has_not : Union[Locator, None]
@@ -17510,7 +17599,8 @@ async def screenshot(
1751017599
caret: typing.Optional[Literal["hide", "initial"]] = None,
1751117600
scale: typing.Optional[Literal["css", "device"]] = None,
1751217601
mask: typing.Optional[typing.Sequence["Locator"]] = None,
17513-
mask_color: typing.Optional[str] = None
17602+
mask_color: typing.Optional[str] = None,
17603+
style: typing.Optional[str] = None
1751417604
) -> bytes:
1751517605
"""Locator.screenshot
1751617606

@@ -17585,6 +17675,10 @@ async def screenshot(
1758517675
mask_color : Union[str, None]
1758617676
Specify the color of the overlay box for masked elements, in
1758717677
[CSS color format](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Default color is pink `#FF00FF`.
17678+
style : Union[str, None]
17679+
Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make
17680+
elements invisible or change their properties to help you creating repeatable screenshots. This stylesheet pierces
17681+
the Shadow DOM and applies to the inner frames.
1758817682

1758917683
Returns
1759017684
-------
@@ -17603,6 +17697,7 @@ async def screenshot(
1760317697
scale=scale,
1760417698
mask=mapping.to_impl(mask),
1760517699
maskColor=mask_color,
17700+
style=style,
1760617701
)
1760717702
)
1760817703

0 commit comments

Comments
 (0)