Skip to content

Commit

Permalink
chore(roll): roll to Playwright 1.41.0-alpha-1702670966000 part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Jan 5, 2024
1 parent 7f35a42 commit e057914
Show file tree
Hide file tree
Showing 16 changed files with 796 additions and 278 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->120.0.6099.28<!-- GEN:stop --> ||||
| Chromium <!-- GEN:chromium-version -->121.0.6167.16<!-- GEN:stop --> ||||
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->119.0<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->120.0.1<!-- GEN:stop --> ||||

## Documentation

Expand Down
7 changes: 7 additions & 0 deletions playwright/_impl/_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ async def _on_route(self, route: Route) -> None:
for route_handler in route_handlers:
if not route_handler.matches(route.request.url):
continue
if route_handler not in self._routes:
continue
if route_handler.will_expire:
self._routes.remove(route_handler)
try:
Expand Down Expand Up @@ -369,6 +371,11 @@ async def unroute(
)
await self._update_interception_patterns()

async def unroute_all(
self, behavior: Literal["default", "ignoreErrors", "wait"] = None
) -> None:
pass

async def _record_into_har(
self,
har: Union[Path, str],
Expand Down
1 change: 1 addition & 0 deletions playwright/_impl/_element_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ async def screenshot(
scale: Literal["css", "device"] = None,
mask: Sequence["Locator"] = None,
maskColor: str = None,
style: str = None,
) -> bytes:
params = locals_to_params(locals())
if "path" in params:
Expand Down
1 change: 1 addition & 0 deletions playwright/_impl/_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ async def screenshot(
scale: Literal["css", "device"] = None,
mask: Sequence["Locator"] = None,
maskColor: str = None,
style: str = None,
) -> bytes:
params = locals_to_params(locals())
return await self._with_element(
Expand Down
8 changes: 8 additions & 0 deletions playwright/_impl/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ async def _on_route(self, route: Route) -> None:
for route_handler in route_handlers:
if not route_handler.matches(route.request.url):
continue
if route_handler not in self._routes:
continue
if route_handler.will_expire:
self._routes.remove(route_handler)
try:
Expand Down Expand Up @@ -593,6 +595,11 @@ async def unroute(
)
await self._update_interception_patterns()

async def unroute_all(
self, behavior: Literal["default", "ignoreErrors", "wait"] = None
) -> None:
pass

async def route_from_har(
self,
har: Union[Path, str],
Expand Down Expand Up @@ -639,6 +646,7 @@ async def screenshot(
scale: Literal["css", "device"] = None,
mask: Sequence["Locator"] = None,
maskColor: str = None,
style: str = None,
) -> bytes:
params = locals_to_params(locals())
if "path" in params:
Expand Down
14 changes: 8 additions & 6 deletions playwright/_impl/_set_input_files_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ async def convert_input_files(
assert isinstance(item, (str, Path))
last_modified_ms = int(os.path.getmtime(item) * 1000)
stream: WritableStream = from_channel(
await context._channel.send(
"createTempFile",
{
"name": os.path.basename(item),
"lastModifiedMs": last_modified_ms,
},
await context._connection.wrap_api_call(
lambda: context._channel.send(
"createTempFile",
{
"name": os.path.basename(cast(str, item)),
"lastModifiedMs": last_modified_ms,
},
)
)
)
await stream.copy(item)
Expand Down
125 changes: 110 additions & 15 deletions playwright/async_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,8 @@ async def screenshot(
caret: typing.Optional[Literal["hide", "initial"]] = None,
scale: typing.Optional[Literal["css", "device"]] = None,
mask: typing.Optional[typing.Sequence["Locator"]] = None,
mask_color: typing.Optional[str] = None
mask_color: typing.Optional[str] = None,
style: typing.Optional[str] = None
) -> bytes:
"""ElementHandle.screenshot

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

Returns
-------
Expand All @@ -2838,6 +2843,7 @@ async def screenshot(
scale=scale,
mask=mapping.to_impl(mask),
maskColor=mask_color,
style=style,
)
)

Expand Down Expand Up @@ -4709,8 +4715,13 @@ def locator(
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
When passed a [string], matching is case-insensitive and searches for a substring.
has : Union[Locator, None]
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.

Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
the document root. For example, you can find `content` that has `div` in
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.

Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
has_not : Union[Locator, None]
Expand Down Expand Up @@ -6245,8 +6256,13 @@ def locator(
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
When passed a [string], matching is case-insensitive and searches for a substring.
has : Union[Locator, None]
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.

Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
the document root. For example, you can find `content` that has `div` in
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.

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

async def unroute_all(
self,
*,
behavior: typing.Optional[Literal["default", "ignoreErrors", "wait"]] = None
) -> None:
"""Page.unroute_all

Removes all routes created with `page.route()` and `page.route_from_har()`.

Parameters
----------
behavior : Union["default", "ignoreErrors", "wait", None]
Specifies wether to wait for already running handlers and what to do if they throw errors:
- `'default'` - do not wait for current handler calls (if any) to finish, if unrouted handler throws, it may
result in unhandled error
- `'wait'` - wait for current handler calls (if any) to finish
- `'ignoreErrors'` - do not wait for current handler calls (if any) to finish, all errors thrown by the handlers
after unrouting are silently caught
"""

return mapping.from_maybe_impl(
await self._impl_obj.unroute_all(behavior=behavior)
)

async def route_from_har(
self,
har: typing.Union[pathlib.Path, str],
Expand Down Expand Up @@ -9924,7 +9964,8 @@ async def screenshot(
caret: typing.Optional[Literal["hide", "initial"]] = None,
scale: typing.Optional[Literal["css", "device"]] = None,
mask: typing.Optional[typing.Sequence["Locator"]] = None,
mask_color: typing.Optional[str] = None
mask_color: typing.Optional[str] = None,
style: typing.Optional[str] = None
) -> bytes:
"""Page.screenshot

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

Returns
-------
Expand All @@ -9993,6 +10038,7 @@ async def screenshot(
scale=scale,
mask=mapping.to_impl(mask),
maskColor=mask_color,
style=style,
)
)

Expand Down Expand Up @@ -10362,8 +10408,13 @@ def locator(
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
When passed a [string], matching is case-insensitive and searches for a substring.
has : Union[Locator, None]
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.

Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
the document root. For example, you can find `content` that has `div` in
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.

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

async def unroute_all(
self,
*,
behavior: typing.Optional[Literal["default", "ignoreErrors", "wait"]] = None
) -> None:
"""BrowserContext.unroute_all

Removes all routes created with `browser_context.route()` and `browser_context.route_from_har()`.

Parameters
----------
behavior : Union["default", "ignoreErrors", "wait", None]
Specifies wether to wait for already running handlers and what to do if they throw errors:
- `'default'` - do not wait for current handler calls (if any) to finish, if unrouted handler throws, it may
result in unhandled error
- `'wait'` - wait for current handler calls (if any) to finish
- `'ignoreErrors'` - do not wait for current handler calls (if any) to finish, all errors thrown by the handlers
after unrouting are silently caught
"""

return mapping.from_maybe_impl(
await self._impl_obj.unroute_all(behavior=behavior)
)

async def route_from_har(
self,
har: typing.Union[pathlib.Path, str],
Expand Down Expand Up @@ -14690,8 +14765,10 @@ async def launch(
"msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using
[Google Chrome and Microsoft Edge](../browsers.md#google-chrome--microsoft-edge).
args : Union[Sequence[str], None]
**NOTE** Use custom browser args at your own risk, as some of them may break Playwright functionality.

Additional arguments to pass to the browser instance. The list of Chromium flags can be found
[here](http://peter.sh/experiments/chromium-command-line-switches/).
[here](https://peter.sh/experiments/chromium-command-line-switches/).
ignore_default_args : Union[Sequence[str], bool, None]
If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is
given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`.
Expand Down Expand Up @@ -14845,8 +14922,10 @@ async def launch_persistent_context(
resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium,
Firefox or WebKit, use at your own risk.
args : Union[Sequence[str], None]
**NOTE** Use custom browser args at your own risk, as some of them may break Playwright functionality.

Additional arguments to pass to the browser instance. The list of Chromium flags can be found
[here](http://peter.sh/experiments/chromium-command-line-switches/).
[here](https://peter.sh/experiments/chromium-command-line-switches/).
ignore_default_args : Union[Sequence[str], bool, None]
If `true`, Playwright does not pass its own configurations args and only uses the ones from `args`. If an array is
given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`.
Expand Down Expand Up @@ -16144,8 +16223,13 @@ def locator(
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
When passed a [string], matching is case-insensitive and searches for a substring.
has : Union[Locator, None]
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.

Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
the document root. For example, you can find `content` that has `div` in
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.

Note that outer and inner locators must belong to the same frame. Inner locator must not contain `FrameLocator`s.
has_not : Union[Locator, None]
Expand Down Expand Up @@ -16806,8 +16890,13 @@ def filter(
Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element.
When passed a [string], matching is case-insensitive and searches for a substring.
has : Union[Locator, None]
Matches elements containing an element that matches an inner locator. Inner locator is queried against the outer
one. For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.
Narrows down the results of the method to those which contain elements matching this relative locator. For example,
`article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.

Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not
the document root. For example, you can find `content` that has `div` in
`<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article
div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.

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

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

Returns
-------
Expand All @@ -17603,6 +17697,7 @@ async def screenshot(
scale=scale,
mask=mapping.to_impl(mask),
maskColor=mask_color,
style=style,
)
)

Expand Down
Loading

0 comments on commit e057914

Please sign in to comment.