Skip to content

Commit 393a060

Browse files
authored
chore: roll Playwright to 1.24.0-beta-1657919681000 (#1439)
Resolves #1398.
1 parent 1c69b53 commit 393a060

File tree

8 files changed

+156
-37
lines changed

8 files changed

+156
-37
lines changed

README.md

Lines changed: 3 additions & 3 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 -->104.0.5112.20<!-- GEN:stop --> ||||
8-
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->100.0.2<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->104.0.5112.48<!-- GEN:stop --> ||||
8+
| WebKit <!-- GEN:webkit-version -->16.0<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->102.0<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

playwright/_impl/_js_handle.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from dataclasses import dataclass
1717
from datetime import datetime
1818
from typing import TYPE_CHECKING, Any, Dict, List, Optional
19+
from urllib.parse import ParseResult, urlparse, urlunparse
1920

2021
from playwright._impl._connection import ChannelOwner, from_channel
2122
from playwright._impl._map import Map
@@ -129,6 +130,8 @@ def serialize_value(
129130
return {"n": value}
130131
if isinstance(value, str):
131132
return {"s": value}
133+
if isinstance(value, ParseResult):
134+
return {"u": urlunparse(value)}
132135

133136
if value in visitor_info.visited:
134137
return dict(ref=visitor_info.visited[value])
@@ -180,6 +183,9 @@ def parse_value(value: Any, refs: Dict[int, Any] = {}) -> Any:
180183
return None
181184
return v
182185

186+
if "u" in value:
187+
return urlparse(value["u"])
188+
183189
if "a" in value:
184190
a: List = []
185191
refs[value["id"]] = a

playwright/_impl/_locator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ def __init__(
7474

7575
if has_text:
7676
if isinstance(has_text, Pattern):
77-
pattern = escape_with_quotes(has_text.pattern, '"')
78-
flags = escape_regex_flags(has_text)
79-
self._selector += f' >> :scope:text-matches({pattern}, "{flags}")'
77+
js_regex = f"/{has_text.pattern}/{escape_regex_flags(has_text)}"
78+
self._selector += f' >> has={json.dumps("text=" + js_regex)}'
8079
else:
8180
escaped = escape_with_quotes(has_text, '"')
8281
self._selector += f" >> :scope:has-text({escaped})"

playwright/async_api/_generated.py

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ async def fallback(
706706
"""Route.fallback
707707

708708
When several routes match the given pattern, they run in the order opposite to their registration. That way the last
709-
registered route can always override all the previos ones. In the example below, request will be handled by the
709+
registered route can always override all the previous ones. In the example below, request will be handled by the
710710
bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
711711
registered route.
712712

@@ -2426,7 +2426,7 @@ async def bounding_box(self) -> typing.Optional[FloatRect]:
24262426
This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
24272427
calculated relative to the main frame viewport - which is usually the same as the browser window.
24282428

2429-
Scrolling affects the returned bonding box, similarly to
2429+
Scrolling affects the returned bounding box, similarly to
24302430
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
24312431
means `x` and/or `y` may be negative.
24322432

@@ -4451,7 +4451,11 @@ async def drag_and_drop(
44514451
Parameters
44524452
----------
44534453
source : str
4454+
A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will be
4455+
used. See [working with selectors](../selectors.md) for more details.
44544456
target : str
4457+
A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first will
4458+
be used. See [working with selectors](../selectors.md) for more details.
44554459
source_position : Union[{x: float, y: float}, NoneType]
44564460
Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
44574461
specified, some visible point of the element is used.
@@ -5302,7 +5306,7 @@ async def run(playwright):
53025306
# Use the selector prefixed with its name.
53035307
button = await page.query_selector('tag=button')
53045308
# Combine it with other selector engines.
5305-
await page.click('tag=div >> text=\"Click me\"')
5309+
await page.locator('tag=div >> text=\"Click me\"').click()
53065310
# Can use it in any methods supporting selectors.
53075311
button_count = await page.locator('tag=button').count()
53085312
print(button_count)
@@ -7764,7 +7768,7 @@ async def route_from_har(
77647768
relative path, then it is resolved relative to the current working directory.
77657769
url : Union[Pattern, str, NoneType]
77667770
A glob pattern, regular expression or predicate to match the request URL. Only requests with URL matching the pattern
7767-
will be surved from the HAR file. If not specified, all requests are served from the HAR file.
7771+
will be served from the HAR file. If not specified, all requests are served from the HAR file.
77687772
not_found : Union["abort", "fallback", NoneType]
77697773
- If set to 'abort' any request not found in the HAR file will be aborted.
77707774
- If set to 'fallback' missing requests will be sent to the network.
@@ -8498,7 +8502,11 @@ async def drag_and_drop(
84988502
Parameters
84998503
----------
85008504
source : str
8505+
A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will be
8506+
used. See [working with selectors](../selectors.md) for more details.
85018507
target : str
8508+
A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first will
8509+
be used. See [working with selectors](../selectors.md) for more details.
85028510
source_position : Union[{x: float, y: float}, NoneType]
85038511
Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
85048512
specified, some visible point of the element is used.
@@ -9723,7 +9731,7 @@ def on(
97239731

97249732
```py
97259733
async with context.expect_page() as page_info:
9726-
await page.click(\"a[target=_blank]\"),
9734+
await page.locator(\"a[target=_blank]\").click(),
97279735
page = await page_info.value
97289736
print(await page.evaluate(\"location.href\"))
97299737
```
@@ -9841,7 +9849,7 @@ def once(
98419849

98429850
```py
98439851
async with context.expect_page() as page_info:
9844-
await page.click(\"a[target=_blank]\"),
9852+
await page.locator(\"a[target=_blank]\").click(),
98459853
page = await page_info.value
98469854
print(await page.evaluate(\"location.href\"))
98479855
```
@@ -10269,7 +10277,7 @@ async def run(playwright):
1026910277
<button onclick=\"onClick()\">Click me</button>
1027010278
<div></div>
1027110279
\"\"\")
10272-
await page.click(\"button\")
10280+
await page.locator(\"button\").click()
1027310281

1027410282
async def main():
1027510283
async with async_playwright() as playwright:
@@ -10347,7 +10355,7 @@ async def run(playwright):
1034710355
<button onclick=\"onClick()\">Click me</button>
1034810356
<div></div>
1034910357
\"\"\")
10350-
await page.click(\"button\")
10358+
await page.locator(\"button\").click()
1035110359

1035210360
async def main():
1035310361
async with async_playwright() as playwright:
@@ -10500,7 +10508,7 @@ async def route_from_har(
1050010508
relative path, then it is resolved relative to the current working directory.
1050110509
url : Union[Pattern, str, NoneType]
1050210510
A glob pattern, regular expression or predicate to match the request URL. Only requests with URL matching the pattern
10503-
will be surved from the HAR file. If not specified, all requests are served from the HAR file.
10511+
will be served from the HAR file. If not specified, all requests are served from the HAR file.
1050410512
not_found : Union["abort", "fallback", NoneType]
1050510513
- If set to 'abort' any request not found in the HAR file will be aborted.
1050610514
- If set to 'fallback' falls through to the next route handler in the handler chain.
@@ -10526,7 +10534,7 @@ def expect_event(
1052610534

1052710535
```py
1052810536
async with context.expect_event(\"page\") as event_info:
10529-
await page.click(\"button\")
10537+
await page.locator(\"button\").click()
1053010538
page = await event_info.value
1053110539
```
1053210540

@@ -10823,13 +10831,22 @@ async def new_context(
1082310831

1082410832
Creates a new browser context. It won't share cookies/cache with other browser contexts.
1082510833

10834+
> NOTE: If directly using this method to create `BrowserContext`s, it is best practice to explicilty close the returned
10835+
context via `browser_context.close()` when your code is done with the `BrowserContext`, and before calling
10836+
`browser.close()`. This will ensure the `context` is closed gracefully and any artifacts—like HARs and
10837+
videos—are fully flushed and saved.
10838+
1082610839
```py
1082710840
browser = await playwright.firefox.launch() # or \"chromium\" or \"webkit\".
1082810841
# create a new incognito browser context.
1082910842
context = await browser.new_context()
1083010843
# create a new page in a pristine context.
1083110844
page = await context.new_page()
1083210845
await page.goto(\"https://example.com\")
10846+
10847+
# gracefully close up everything
10848+
await context.close()
10849+
await browser.close()
1083310850
```
1083410851

1083510852
Parameters
@@ -11181,6 +11198,10 @@ async def close(self) -> NoneType:
1118111198
In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
1118211199
browser server.
1118311200

11201+
> NOTE: This is similar to force quitting the browser. Therefore, you should call `browser_context.close()` on
11202+
any `BrowserContext`'s you explicitly created earlier with `browser.new_context()` **before** calling
11203+
`browser.close()`.
11204+
1118411205
The `Browser` object itself is considered to be disposed and cannot be used anymore.
1118511206
"""
1118611207

@@ -11950,7 +11971,7 @@ async def start_chunk(self, *, title: str = None) -> NoneType:
1195011971
await page.goto(\"https://playwright.dev\")
1195111972

1195211973
await context.tracing.start_chunk()
11953-
await page.click(\"text=Get Started\")
11974+
await page.locator(\"text=Get Started\").click()
1195411975
# Everything between start_chunk and stop_chunk will be recorded in the trace.
1195511976
await context.tracing.stop_chunk(path = \"trace1.zip\")
1195611977

@@ -12045,7 +12066,7 @@ async def bounding_box(
1204512066
This method returns the bounding box of the element, or `null` if the element is not visible. The bounding box is
1204612067
calculated relative to the main frame viewport - which is usually the same as the browser window.
1204712068

12048-
Scrolling affects the returned bonding box, similarly to
12069+
Scrolling affects the returned bounding box, similarly to
1204912070
[Element.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). That
1205012071
means `x` and/or `y` may be negative.
1205112072

@@ -14301,7 +14322,7 @@ async def to_have_url(
1430114322
Parameters
1430214323
----------
1430314324
url_or_reg_exp : Union[Pattern, str]
14304-
Expected substring or RegExp.
14325+
Expected URL string or RegExp.
1430514326
timeout : Union[float, NoneType]
1430614327
Time to retry the assertion for.
1430714328
"""
@@ -14326,7 +14347,7 @@ async def not_to_have_url(
1432614347
Parameters
1432714348
----------
1432814349
url_or_reg_exp : Union[Pattern, str]
14329-
Expected substring or RegExp.
14350+
Expected URL string or RegExp.
1433014351
timeout : Union[float, NoneType]
1433114352
Time to retry the assertion for.
1433214353
"""
@@ -14510,13 +14531,19 @@ async def to_have_class(
1451014531
) -> NoneType:
1451114532
"""LocatorAssertions.to_have_class
1451214533

14513-
Ensures the `Locator` points to an element with given CSS class.
14534+
Ensures the `Locator` points to an element with given CSS classes. This needs to be a full match or using a relaxed
14535+
regular expression.
14536+
14537+
```html
14538+
<div class='selected row' id='component'></div>
14539+
```
1451414540

1451514541
```py
1451614542
from playwright.async_api import expect
1451714543

1451814544
locator = page.locator(\"#component\")
1451914545
await expect(locator).to_have_class(re.compile(r\"selected\"))
14546+
await expect(locator).to_have_class(\"selected row\")
1452014547
```
1452114548

1452214549
Note that if array is passed as an expected value, entire lists of elements can be asserted:

0 commit comments

Comments
 (0)