Skip to content

Commit 4ecf61e

Browse files
authored
fix(assertions): allow tuple as valid input type for expected text values (#2723)
1 parent 9010889 commit 4ecf61e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

playwright/_impl/_assertions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ def to_expected_text_values(
874874
ignoreCase: Optional[bool] = None,
875875
) -> Sequence[ExpectedTextValue]:
876876
out: List[ExpectedTextValue] = []
877-
assert isinstance(items, list)
877+
assert isinstance(items, (list, tuple))
878878
for item in items:
879879
if isinstance(item, str):
880880
o = ExpectedTextValue(

tests/async/test_assertions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ async def test_assertions_locator_to_have_text(page: Page, server: Server) -> No
274274
await expect(page.locator("div")).to_have_text(
275275
["Text 1", re.compile(r"Text \d+a")]
276276
)
277+
# Should work with a tuple
278+
await expect(page.locator("div")).to_have_text(
279+
("Text 1", re.compile(r"Text \d+a"))
280+
)
277281

278282

279283
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)