Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add get_by_text escaping with multiple space sequences #1582

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 28 additions & 18 deletions tests/sync/test_locator_get_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,35 +153,45 @@ def test_get_by_title(page: Page) -> None:

def test_get_by_escaping(page: Page) -> None:
page.set_content(
"""<label id=label for=control>Hello
"""<label id=label for=control>Hello my
wo"rld</label><input id=control />"""
)
page.locator("input").evaluate(
"""input => {
input.setAttribute('placeholder', 'hello\\nwo"rld');
input.setAttribute('title', 'hello\\nwo"rld');
input.setAttribute('alt', 'hello\\nwo"rld');
input.setAttribute('placeholder', 'hello my\\nwo"rld');
input.setAttribute('title', 'hello my\\nwo"rld');
input.setAttribute('alt', 'hello my\\nwo"rld');
}"""
)
expect(page.get_by_text('hello\nwo"rld')).to_have_attribute("id", "label")
expect(page.get_by_label('hello\nwo"rld')).to_have_attribute("id", "control")
expect(page.get_by_placeholder('hello\nwo"rld')).to_have_attribute("id", "control")
expect(page.get_by_alt_text('hello\nwo"rld')).to_have_attribute("id", "control")
expect(page.get_by_title('hello\nwo"rld')).to_have_attribute("id", "control")
expect(page.get_by_text('hello my\nwo"rld')).to_have_attribute("id", "label")
expect(page.get_by_text('hello my wo"rld')).to_have_attribute(
"id", "label"
)
expect(page.get_by_label('hello my\nwo"rld')).to_have_attribute("id", "control")
expect(page.get_by_placeholder('hello my\nwo"rld')).to_have_attribute(
"id", "control"
)
expect(page.get_by_alt_text('hello my\nwo"rld')).to_have_attribute("id", "control")
expect(page.get_by_title('hello my\nwo"rld')).to_have_attribute("id", "control")

page.set_content(
"""<label id=label for=control>Hello
"""<label id=label for=control>Hello my
world</label><input id=control />"""
)
page.locator("input").evaluate(
"""input => {
input.setAttribute('placeholder', 'hello\\nworld');
input.setAttribute('title', 'hello\\nworld');
input.setAttribute('alt', 'hello\\nworld');
input.setAttribute('placeholder', 'hello my\\nworld');
input.setAttribute('title', 'hello my\\nworld');
input.setAttribute('alt', 'hello my\\nworld');
}"""
)
expect(page.get_by_text("hello\nworld")).to_have_attribute("id", "label")
expect(page.get_by_label("hello\nworld")).to_have_attribute("id", "control")
expect(page.get_by_placeholder("hello\nworld")).to_have_attribute("id", "control")
expect(page.get_by_alt_text("hello\nworld")).to_have_attribute("id", "control")
expect(page.get_by_title("hello\nworld")).to_have_attribute("id", "control")
expect(page.get_by_text("hello my\nworld")).to_have_attribute("id", "label")
expect(page.get_by_text("hello my world")).to_have_attribute(
"id", "label"
)
expect(page.get_by_label("hello my\nworld")).to_have_attribute("id", "control")
expect(page.get_by_placeholder("hello my\nworld")).to_have_attribute(
"id", "control"
)
expect(page.get_by_alt_text("hello my\nworld")).to_have_attribute("id", "control")
expect(page.get_by_title("hello my\nworld")).to_have_attribute("id", "control")