Skip to content

Commit

Permalink
test: unflake test_locators_should_support_locator_and (#2290)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Feb 11, 2024
1 parent d921434 commit 57ba22e
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions tests/async/test_selector_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,30 @@ async def test_should_use_data_test_id_in_strict_errors(
page: Page, playwright: Playwright
) -> None:
playwright.selectors.set_test_id_attribute("data-custom-id")
await page.set_content(
try:
await page.set_content(
"""
<div>
<div></div>
<div>
<div></div>
<div></div>
</div>
</div>
<div>
<div class='foo bar:0' data-custom-id='One'>
</div>
<div class='foo bar:1' data-custom-id='Two'>
</div>
</div>
"""
<div>
<div></div>
<div>
<div></div>
<div></div>
</div>
</div>
<div>
<div class='foo bar:0' data-custom-id='One'>
</div>
<div class='foo bar:1' data-custom-id='Two'>
</div>
</div>
"""
)
with pytest.raises(Error) as exc_info:
await page.locator(".foo").hover(timeout=200)
assert "strict mode violation" in exc_info.value.message
assert '<div class="foo bar:0' in exc_info.value.message
assert '<div class="foo bar:1' in exc_info.value.message
assert 'aka get_by_test_id("One")' in exc_info.value.message
assert 'aka get_by_test_id("Two")' in exc_info.value.message
)
with pytest.raises(Error) as exc_info:
await page.locator(".foo").hover(timeout=200)
assert "strict mode violation" in exc_info.value.message
assert '<div class="foo bar:0' in exc_info.value.message
assert '<div class="foo bar:1' in exc_info.value.message
assert 'aka get_by_test_id("One")' in exc_info.value.message
assert 'aka get_by_test_id("Two")' in exc_info.value.message
finally:
playwright.selectors.set_test_id_attribute("data-testid")

0 comments on commit 57ba22e

Please sign in to comment.