Skip to content

Commit 525dbce

Browse files
authored
chore(roll): roll Playwright to 1.33.0-alpha-apr-12-2023 (microsoft#1859)
1 parent 56a40a5 commit 525dbce

20 files changed

+1117
-152
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
44

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->112.0.5615.29<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->113.0.5672.24<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->16.4<!-- GEN:stop --> ||||
99
| Firefox <!-- GEN:firefox-version -->111.0<!-- GEN:stop --> ||||
1010

playwright/_impl/_api_structures.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ class Geolocation(TypedDict, total=False):
6464
accuracy: Optional[float]
6565

6666

67-
class HttpCredentials(TypedDict):
67+
class HttpCredentials(TypedDict, total=False):
6868
username: str
6969
password: str
70+
origin: Optional[str]
7071

7172

7273
class LocalStorageEntry(TypedDict):

playwright/_impl/_assertions.py

+23
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,21 @@ async def not_to_have_text(
464464
__tracebackhide__ = True
465465
await self._not.to_have_text(expected, use_inner_text, timeout, ignore_case)
466466

467+
async def to_be_attached(
468+
self,
469+
attached: bool = None,
470+
timeout: float = None,
471+
) -> None:
472+
__tracebackhide__ = True
473+
await self._expect_impl(
474+
"to.be.attached"
475+
if (attached is None or attached is True)
476+
else "to.be.detached",
477+
FrameExpectOptions(timeout=timeout),
478+
None,
479+
"Locator expected to be attached",
480+
)
481+
467482
async def to_be_checked(
468483
self,
469484
timeout: float = None,
@@ -479,6 +494,14 @@ async def to_be_checked(
479494
"Locator expected to be checked",
480495
)
481496

497+
async def not_to_be_attached(
498+
self,
499+
attached: bool = None,
500+
timeout: float = None,
501+
) -> None:
502+
__tracebackhide__ = True
503+
await self._not.to_be_attached(attached=attached, timeout=timeout)
504+
482505
async def not_to_be_checked(
483506
self,
484507
timeout: float = None,

playwright/_impl/_browser_type.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,17 @@ async def connect(
191191

192192
headers = {**(headers if headers else {}), "x-playwright-browser": self.name}
193193
local_utils = self._connection.local_utils
194-
pipe_channel = await local_utils._channel.send(
195-
"connect",
196-
{
197-
"wsEndpoint": ws_endpoint,
198-
"headers": headers,
199-
"slowMo": slow_mo,
200-
"timeout": timeout,
201-
},
202-
)
194+
pipe_channel = (
195+
await local_utils._channel.send_return_as_dict(
196+
"connect",
197+
{
198+
"wsEndpoint": ws_endpoint,
199+
"headers": headers,
200+
"slowMo": slow_mo,
201+
"timeout": timeout,
202+
},
203+
)
204+
)["pipe"]
203205
transport = JsonPipeTransport(self._connection._loop, pipe_channel)
204206

205207
connection = Connection(

playwright/_impl/_frame.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,18 @@ def locator(
531531
self,
532532
selector: str,
533533
has_text: Union[str, Pattern[str]] = None,
534+
has_not_text: Union[str, Pattern[str]] = None,
534535
has: Locator = None,
536+
has_not: Locator = None,
535537
) -> Locator:
536-
return Locator(self, selector, has_text=has_text, has=has)
538+
return Locator(
539+
self,
540+
selector,
541+
has_text=has_text,
542+
has_not_text=has_not_text,
543+
has=has,
544+
has_not=has_not,
545+
)
537546

538547
def get_by_alt_text(
539548
self, text: Union[str, Pattern[str]], exact: bool = None

playwright/_impl/_locator.py

+35
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def __init__(
7373
frame: "Frame",
7474
selector: str,
7575
has_text: Union[str, Pattern[str]] = None,
76+
has_not_text: Union[str, Pattern[str]] = None,
7677
has: "Locator" = None,
78+
has_not: "Locator" = None,
7779
) -> None:
7880
self._frame = frame
7981
self._selector = selector
@@ -90,6 +92,15 @@ def __init__(
9092
has._selector, ensure_ascii=False
9193
)
9294

95+
if has_not_text:
96+
self._selector += f" >> internal:has-not-text={escape_for_text_selector(has_not_text, exact=False)}"
97+
98+
if has_not:
99+
locator = has_not
100+
if locator._frame != frame:
101+
raise Error('Inner "has_not" locator must belong to the same frame.')
102+
self._selector += " >> internal:has-not=" + json.dumps(locator._selector)
103+
93104
def __repr__(self) -> str:
94105
return f"<Locator frame={self._frame!r} selector={self._selector!r}>"
95106

@@ -211,13 +222,17 @@ def locator(
211222
self,
212223
selector_or_locator: Union[str, "Locator"],
213224
has_text: Union[str, Pattern[str]] = None,
225+
has_not_text: Union[str, Pattern[str]] = None,
214226
has: "Locator" = None,
227+
has_not: "Locator" = None,
215228
) -> "Locator":
216229
if isinstance(selector_or_locator, str):
217230
return Locator(
218231
self._frame,
219232
f"{self._selector} >> {selector_or_locator}",
220233
has_text=has_text,
234+
has_not_text=has_not_text,
235+
has_not=has_not,
221236
has=has,
222237
)
223238
selector_or_locator = to_impl(selector_or_locator)
@@ -227,6 +242,8 @@ def locator(
227242
self._frame,
228243
f"{self._selector} >> {selector_or_locator._selector}",
229244
has_text=has_text,
245+
has_not_text=has_not_text,
246+
has_not=has_not,
230247
has=has,
231248
)
232249

@@ -317,13 +334,25 @@ def nth(self, index: int) -> "Locator":
317334
def filter(
318335
self,
319336
has_text: Union[str, Pattern[str]] = None,
337+
has_not_text: Union[str, Pattern[str]] = None,
320338
has: "Locator" = None,
339+
has_not: "Locator" = None,
321340
) -> "Locator":
322341
return Locator(
323342
self._frame,
324343
self._selector,
325344
has_text=has_text,
345+
has_not_text=has_not_text,
326346
has=has,
347+
has_not=has_not,
348+
)
349+
350+
def or_(self, locator: "Locator") -> "Locator":
351+
if locator._frame != self._frame:
352+
raise Error("Locators must belong to the same frame.")
353+
return Locator(
354+
self._frame,
355+
self._selector + " >> internal:or=" + json.dumps(locator._selector),
327356
)
328357

329358
async def focus(self, timeout: float = None) -> None:
@@ -677,14 +706,18 @@ def locator(
677706
self,
678707
selector_or_locator: Union["Locator", str],
679708
has_text: Union[str, Pattern[str]] = None,
709+
has_not_text: Union[str, Pattern[str]] = None,
680710
has: "Locator" = None,
711+
has_not: "Locator" = None,
681712
) -> Locator:
682713
if isinstance(selector_or_locator, str):
683714
return Locator(
684715
self._frame,
685716
f"{self._frame_selector} >> internal:control=enter-frame >> {selector_or_locator}",
686717
has_text=has_text,
718+
has_not_text=has_not_text,
687719
has=has,
720+
has_not=has_not,
688721
)
689722
selector_or_locator = to_impl(selector_or_locator)
690723
if selector_or_locator._frame != self._frame:
@@ -693,7 +726,9 @@ def locator(
693726
self._frame,
694727
f"{self._frame_selector} >> internal:control=enter-frame >> {selector_or_locator._selector}",
695728
has_text=has_text,
729+
has_not_text=has_not_text,
696730
has=has,
731+
has_not=has_not,
697732
)
698733

699734
def get_by_alt_text(

playwright/_impl/_network.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from typing import TypedDict
3939
else: # pragma: no cover
4040
from typing_extensions import TypedDict
41+
4142
from urllib import parse
4243

4344
from playwright._impl._api_structures import (
@@ -51,6 +52,7 @@
5152
from playwright._impl._api_types import Error
5253
from playwright._impl._connection import (
5354
ChannelOwner,
55+
filter_none,
5456
from_channel,
5557
from_nullable_channel,
5658
)
@@ -278,7 +280,15 @@ def request(self) -> Request:
278280
async def abort(self, errorCode: str = None) -> None:
279281
self._check_not_handled()
280282
await self._race_with_page_close(
281-
self._channel.send("abort", locals_to_params(locals()))
283+
self._channel.send(
284+
"abort",
285+
filter_none(
286+
{
287+
"errorCode": errorCode,
288+
"requestUrl": self.request._initializer["url"],
289+
}
290+
),
291+
)
282292
)
283293
self._report_handled(True)
284294

@@ -344,6 +354,8 @@ async def fulfill(
344354
if length and "content-length" not in headers:
345355
headers["content-length"] = str(length)
346356
params["headers"] = serialize_headers(headers)
357+
params["requestUrl"] = self.request._initializer["url"]
358+
347359
await self._race_with_page_close(self._channel.send("fulfill", params))
348360
self._report_handled(True)
349361

@@ -402,6 +414,7 @@ async def continue_route() -> None:
402414

403415
if "headers" in params:
404416
params["headers"] = serialize_headers(params["headers"])
417+
params["requestUrl"] = self.request._initializer["url"]
405418
await self._connection.wrap_api_call(
406419
lambda: self._race_with_page_close(
407420
self._channel.send(

playwright/_impl/_page.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,17 @@ def locator(
754754
self,
755755
selector: str,
756756
has_text: Union[str, Pattern[str]] = None,
757+
has_not_text: Union[str, Pattern[str]] = None,
757758
has: "Locator" = None,
759+
has_not: "Locator" = None,
758760
) -> "Locator":
759-
return self._main_frame.locator(selector, has_text=has_text, has=has)
761+
return self._main_frame.locator(
762+
selector,
763+
has_text=has_text,
764+
has_not_text=has_not_text,
765+
has=has,
766+
has_not=has_not,
767+
)
760768

761769
def get_by_alt_text(
762770
self, text: Union[str, Pattern[str]], exact: bool = None

0 commit comments

Comments
 (0)