Skip to content

Commit ae0d36b

Browse files
committed
chore: roll to 1.23 (1.23.0-alpha-1655778679000)
- fromServiceWorkers - toHaveValues - browserType - ignoreCase
1 parent 5d33195 commit ae0d36b

19 files changed

+3479
-96
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 -->102.0.5005.61<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->103.0.5060.53<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->99.0.1<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->100.0.2<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

playwright/_impl/_api_structures.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class ExpectedTextValue(TypedDict, total=False):
179179
regexFlags: str
180180
matchSubstring: bool
181181
normalizeWhiteSpace: bool
182+
ignoreCase: Optional[bool]
182183

183184

184185
class FrameExpectOptions(TypedDict, total=False):

playwright/_impl/_assertions.py

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Any, List, Pattern, Union
15+
from typing import Any, List, Optional, Pattern, Union
1616
from urllib.parse import urljoin
1717

1818
from playwright._impl._api_structures import ExpectedTextValue, FrameExpectOptions
@@ -122,11 +122,15 @@ async def to_contain_text(
122122
expected: Union[List[Union[Pattern, str]], Pattern, str],
123123
use_inner_text: bool = None,
124124
timeout: float = None,
125+
ignore_case: bool = None,
125126
) -> None:
126127
__tracebackhide__ = True
127128
if isinstance(expected, list):
128129
expected_text = to_expected_text_values(
129-
expected, match_substring=True, normalize_white_space=True
130+
expected,
131+
match_substring=True,
132+
normalize_white_space=True,
133+
ignore_case=ignore_case,
130134
)
131135
await self._expect_impl(
132136
"to.contain.text.array",
@@ -140,7 +144,10 @@ async def to_contain_text(
140144
)
141145
else:
142146
expected_text = to_expected_text_values(
143-
[expected], match_substring=True, normalize_white_space=True
147+
[expected],
148+
match_substring=True,
149+
normalize_white_space=True,
150+
ignore_case=ignore_case,
144151
)
145152
await self._expect_impl(
146153
"to.have.text",
@@ -158,9 +165,10 @@ async def not_to_contain_text(
158165
expected: Union[List[Union[Pattern, str]], Pattern, str],
159166
use_inner_text: bool = None,
160167
timeout: float = None,
168+
ignore_case: bool = None,
161169
) -> None:
162170
__tracebackhide__ = True
163-
await self._not.to_contain_text(expected, use_inner_text, timeout)
171+
await self._not.to_contain_text(expected, use_inner_text, timeout, ignore_case)
164172

165173
async def to_have_attribute(
166174
self,
@@ -335,16 +343,41 @@ async def not_to_have_value(
335343
__tracebackhide__ = True
336344
await self._not.to_have_value(value, timeout)
337345

346+
async def to_have_values(
347+
self,
348+
values: List[Union[Pattern, str]],
349+
timeout: float = None,
350+
) -> None:
351+
__tracebackhide__ = True
352+
expected_text = to_expected_text_values(values)
353+
await self._expect_impl(
354+
"to.have.values",
355+
FrameExpectOptions(expectedText=expected_text, timeout=timeout),
356+
values,
357+
"Locator expected to have Values",
358+
)
359+
360+
async def not_to_have_values(
361+
self,
362+
values: List[Union[Pattern, str]],
363+
timeout: float = None,
364+
) -> None:
365+
__tracebackhide__ = True
366+
await self._not.to_have_values(values, timeout)
367+
338368
async def to_have_text(
339369
self,
340370
expected: Union[List[Union[Pattern, str]], Pattern, str],
341371
use_inner_text: bool = None,
342372
timeout: float = None,
373+
ignore_case: bool = None,
343374
) -> None:
344375
__tracebackhide__ = True
345376
if isinstance(expected, list):
346377
expected_text = to_expected_text_values(
347-
expected, normalize_white_space=True
378+
expected,
379+
normalize_white_space=True,
380+
ignore_case=ignore_case,
348381
)
349382
await self._expect_impl(
350383
"to.have.text.array",
@@ -358,7 +391,7 @@ async def to_have_text(
358391
)
359392
else:
360393
expected_text = to_expected_text_values(
361-
[expected], normalize_white_space=True
394+
[expected], normalize_white_space=True, ignore_case=ignore_case
362395
)
363396
await self._expect_impl(
364397
"to.have.text",
@@ -376,9 +409,10 @@ async def not_to_have_text(
376409
expected: Union[List[Union[Pattern, str]], Pattern, str],
377410
use_inner_text: bool = None,
378411
timeout: float = None,
412+
ignore_case: bool = None,
379413
) -> None:
380414
__tracebackhide__ = True
381-
await self._not.to_have_text(expected, use_inner_text, timeout)
415+
await self._not.to_have_text(expected, use_inner_text, timeout, ignore_case)
382416

383417
async def to_be_checked(
384418
self,
@@ -568,33 +602,46 @@ async def not_to_be_ok(self) -> None:
568602

569603

570604
def expected_regex(
571-
pattern: Pattern, match_substring: bool, normalize_white_space: bool
605+
pattern: Pattern,
606+
match_substring: bool,
607+
normalize_white_space: bool,
608+
ignore_case: Optional[bool] = None,
572609
) -> ExpectedTextValue:
573610
expected = ExpectedTextValue(
574611
regexSource=pattern.pattern,
575612
regexFlags=escape_regex_flags(pattern),
576613
matchSubstring=match_substring,
577614
normalizeWhiteSpace=normalize_white_space,
615+
ignoreCase=ignore_case,
578616
)
617+
if expected["ignoreCase"] is None:
618+
del expected["ignoreCase"]
579619
return expected
580620

581621

582622
def to_expected_text_values(
583623
items: Union[List[Pattern], List[str], List[Union[str, Pattern]]],
584624
match_substring: bool = False,
585625
normalize_white_space: bool = False,
626+
ignore_case: Optional[bool] = None,
586627
) -> List[ExpectedTextValue]:
587628
out: List[ExpectedTextValue] = []
588629
assert isinstance(items, list)
589630
for item in items:
590631
if isinstance(item, str):
632+
o = ExpectedTextValue(
633+
string=item,
634+
matchSubstring=match_substring,
635+
normalizeWhiteSpace=normalize_white_space,
636+
ignoreCase=ignore_case,
637+
)
638+
if o["ignoreCase"] is None:
639+
del o["ignoreCase"]
640+
out.append(o)
641+
elif isinstance(item, Pattern):
591642
out.append(
592-
ExpectedTextValue(
593-
string=item,
594-
matchSubstring=match_substring,
595-
normalizeWhiteSpace=normalize_white_space,
643+
expected_regex(
644+
item, match_substring, normalize_white_space, ignore_case
596645
)
597646
)
598-
elif isinstance(item, Pattern):
599-
out.append(expected_regex(item, match_substring, normalize_white_space))
600647
return out

playwright/_impl/_browser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
ColorScheme,
3333
ForcedColors,
3434
ReducedMotion,
35+
ServiceWorkersPolicy,
3536
async_readfile,
3637
is_safe_close_error,
3738
locals_to_params,
@@ -75,6 +76,10 @@ def _on_close(self) -> None:
7576
def contexts(self) -> List[BrowserContext]:
7677
return self._contexts.copy()
7778

79+
@property
80+
def browser_type(self) -> "BrowserType":
81+
return self._browser_type
82+
7883
def is_connected(self) -> bool:
7984
return self._is_connected
8085

@@ -110,6 +115,7 @@ async def new_context(
110115
storageState: Union[StorageState, str, Path] = None,
111116
baseURL: str = None,
112117
strictSelectors: bool = None,
118+
serviceWorkers: ServiceWorkersPolicy = None,
113119
) -> BrowserContext:
114120
params = locals_to_params(locals())
115121
await normalize_context_params(self._connection._is_sync, params)
@@ -154,6 +160,7 @@ async def new_page(
154160
storageState: Union[StorageState, str, Path] = None,
155161
baseURL: str = None,
156162
strictSelectors: bool = None,
163+
serviceWorkers: ServiceWorkersPolicy = None,
157164
) -> Page:
158165
params = locals_to_params(locals())
159166
context = await self.new_context(**params)

playwright/_impl/_browser_type.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
Env,
3838
ForcedColors,
3939
ReducedMotion,
40+
ServiceWorkersPolicy,
4041
locals_to_params,
4142
)
4243
from playwright._impl._transport import WebSocketTransport
@@ -138,6 +139,7 @@ async def launch_persistent_context(
138139
recordVideoSize: ViewportSize = None,
139140
baseURL: str = None,
140141
strictSelectors: bool = None,
142+
serviceWorkers: ServiceWorkersPolicy = None,
141143
) -> BrowserContext:
142144
userDataDir = str(Path(userDataDir))
143145
params = locals_to_params(locals())

playwright/_impl/_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
DocumentLoadState = Literal["commit", "domcontentloaded", "load", "networkidle"]
6363
KeyboardModifier = Literal["Alt", "Control", "Meta", "Shift"]
6464
MouseButton = Literal["left", "middle", "right"]
65+
ServiceWorkersPolicy = Literal["allow", "block"]
6566

6667

6768
class ErrorPayload(TypedDict, total=False):

playwright/_impl/_network.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ def status_text(self) -> str:
343343
def headers(self) -> Headers:
344344
return self._provisional_headers.headers()
345345

346+
@property
347+
def from_service_worker(self) -> bool:
348+
return self._initializer["fromServiceWorker"]
349+
346350
async def all_headers(self) -> Headers:
347351
return (await self._actual_headers()).headers()
348352

0 commit comments

Comments
 (0)