@@ -2769,7 +2769,8 @@ async def screenshot(
2769
2769
caret: typing.Optional[Literal["hide", "initial"]] = None,
2770
2770
scale: typing.Optional[Literal["css", "device"]] = None,
2771
2771
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
2773
2774
) -> bytes:
2774
2775
"""ElementHandle.screenshot
2775
2776
@@ -2820,6 +2821,10 @@ async def screenshot(
2820
2821
mask_color : Union[str, None]
2821
2822
Specify the color of the overlay box for masked elements, in
2822
2823
[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.
2823
2828
2824
2829
Returns
2825
2830
-------
@@ -2838,6 +2843,7 @@ async def screenshot(
2838
2843
scale=scale,
2839
2844
mask=mapping.to_impl(mask),
2840
2845
maskColor=mask_color,
2846
+ style=style,
2841
2847
)
2842
2848
)
2843
2849
@@ -4709,8 +4715,13 @@ def locator(
4709
4715
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
4710
4716
When passed a [string], matching is case-insensitive and searches for a substring.
4711
4717
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`.
4714
4725
4715
4726
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
4716
4727
has_not : Union[Locator, None]
@@ -6245,8 +6256,13 @@ def locator(
6245
6256
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
6246
6257
When passed a [string], matching is case-insensitive and searches for a substring.
6247
6258
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`.
6250
6266
6251
6267
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
6252
6268
has_not : Union[Locator, None]
@@ -9856,6 +9872,30 @@ async def unroute(
9856
9872
)
9857
9873
)
9858
9874
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
+
9859
9899
async def route_from_har(
9860
9900
self,
9861
9901
har: typing.Union[pathlib.Path, str],
@@ -9924,7 +9964,8 @@ async def screenshot(
9924
9964
caret: typing.Optional[Literal["hide", "initial"]] = None,
9925
9965
scale: typing.Optional[Literal["css", "device"]] = None,
9926
9966
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
9928
9969
) -> bytes:
9929
9970
"""Page.screenshot
9930
9971
@@ -9973,6 +10014,10 @@ async def screenshot(
9973
10014
mask_color : Union[str, None]
9974
10015
Specify the color of the overlay box for masked elements, in
9975
10016
[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.
9976
10021
9977
10022
Returns
9978
10023
-------
@@ -9993,6 +10038,7 @@ async def screenshot(
9993
10038
scale=scale,
9994
10039
mask=mapping.to_impl(mask),
9995
10040
maskColor=mask_color,
10041
+ style=style,
9996
10042
)
9997
10043
)
9998
10044
@@ -10362,8 +10408,13 @@ def locator(
10362
10408
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
10363
10409
When passed a [string], matching is case-insensitive and searches for a substring.
10364
10410
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`.
10367
10418
10368
10419
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
10369
10420
has_not : Union[Locator, None]
@@ -13640,6 +13691,30 @@ async def unroute(
13640
13691
)
13641
13692
)
13642
13693
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
+
13643
13718
async def route_from_har(
13644
13719
self,
13645
13720
har: typing.Union[pathlib.Path, str],
@@ -14690,8 +14765,10 @@ async def launch(
14690
14765
"msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using
14691
14766
[Google Chrome and Microsoft Edge](../browsers.md#google-chrome--microsoft-edge).
14692
14767
args : Union[Sequence[str], None]
14768
+ **NOTE** Use custom browser args at your own risk, as some of them may break Playwright functionality.
14769
+
14693
14770
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/).
14695
14772
ignore_default_args : Union[Sequence[str], bool, None]
14696
14773
If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is
14697
14774
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(
14845
14922
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium,
14846
14923
Firefox or WebKit, use at your own risk.
14847
14924
args : Union[Sequence[str], None]
14925
+ **NOTE** Use custom browser args at your own risk, as some of them may break Playwright functionality.
14926
+
14848
14927
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/).
14850
14929
ignore_default_args : Union[Sequence[str], bool, None]
14851
14930
If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is
14852
14931
given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`.
@@ -16144,8 +16223,13 @@ def locator(
16144
16223
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
16145
16224
When passed a [string], matching is case-insensitive and searches for a substring.
16146
16225
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`.
16149
16233
16150
16234
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
16151
16235
has_not : Union[Locator, None]
@@ -16806,8 +16890,13 @@ def filter(
16806
16890
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
16807
16891
When passed a [string], matching is case-insensitive and searches for a substring.
16808
16892
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`.
16811
16900
16812
16901
Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
16813
16902
has_not : Union[Locator, None]
@@ -17510,7 +17599,8 @@ async def screenshot(
17510
17599
caret: typing.Optional[Literal["hide", "initial"]] = None,
17511
17600
scale: typing.Optional[Literal["css", "device"]] = None,
17512
17601
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
17514
17604
) -> bytes:
17515
17605
"""Locator.screenshot
17516
17606
@@ -17585,6 +17675,10 @@ async def screenshot(
17585
17675
mask_color : Union[str, None]
17586
17676
Specify the color of the overlay box for masked elements, in
17587
17677
[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.
17588
17682
17589
17683
Returns
17590
17684
-------
@@ -17603,6 +17697,7 @@ async def screenshot(
17603
17697
scale=scale,
17604
17698
mask=mapping.to_impl(mask),
17605
17699
maskColor=mask_color,
17700
+ style=style,
17606
17701
)
17607
17702
)
17608
17703
0 commit comments