Skip to content

Commit be076b7

Browse files
authored
test: add get_by_text escaping with multiple space sequences (microsoft#1582)
Mirrors upstream test. Implementation is already good.
1 parent bddee13 commit be076b7

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

tests/sync/test_locator_get_by.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,35 +153,45 @@ def test_get_by_title(page: Page) -> None:
153153

154154
def test_get_by_escaping(page: Page) -> None:
155155
page.set_content(
156-
"""<label id=label for=control>Hello
156+
"""<label id=label for=control>Hello my
157157
wo"rld</label><input id=control />"""
158158
)
159159
page.locator("input").evaluate(
160160
"""input => {
161-
input.setAttribute('placeholder', 'hello\\nwo"rld');
162-
input.setAttribute('title', 'hello\\nwo"rld');
163-
input.setAttribute('alt', 'hello\\nwo"rld');
161+
input.setAttribute('placeholder', 'hello my\\nwo"rld');
162+
input.setAttribute('title', 'hello my\\nwo"rld');
163+
input.setAttribute('alt', 'hello my\\nwo"rld');
164164
}"""
165165
)
166-
expect(page.get_by_text('hello\nwo"rld')).to_have_attribute("id", "label")
167-
expect(page.get_by_label('hello\nwo"rld')).to_have_attribute("id", "control")
168-
expect(page.get_by_placeholder('hello\nwo"rld')).to_have_attribute("id", "control")
169-
expect(page.get_by_alt_text('hello\nwo"rld')).to_have_attribute("id", "control")
170-
expect(page.get_by_title('hello\nwo"rld')).to_have_attribute("id", "control")
166+
expect(page.get_by_text('hello my\nwo"rld')).to_have_attribute("id", "label")
167+
expect(page.get_by_text('hello my wo"rld')).to_have_attribute(
168+
"id", "label"
169+
)
170+
expect(page.get_by_label('hello my\nwo"rld')).to_have_attribute("id", "control")
171+
expect(page.get_by_placeholder('hello my\nwo"rld')).to_have_attribute(
172+
"id", "control"
173+
)
174+
expect(page.get_by_alt_text('hello my\nwo"rld')).to_have_attribute("id", "control")
175+
expect(page.get_by_title('hello my\nwo"rld')).to_have_attribute("id", "control")
171176

172177
page.set_content(
173-
"""<label id=label for=control>Hello
178+
"""<label id=label for=control>Hello my
174179
world</label><input id=control />"""
175180
)
176181
page.locator("input").evaluate(
177182
"""input => {
178-
input.setAttribute('placeholder', 'hello\\nworld');
179-
input.setAttribute('title', 'hello\\nworld');
180-
input.setAttribute('alt', 'hello\\nworld');
183+
input.setAttribute('placeholder', 'hello my\\nworld');
184+
input.setAttribute('title', 'hello my\\nworld');
185+
input.setAttribute('alt', 'hello my\\nworld');
181186
}"""
182187
)
183-
expect(page.get_by_text("hello\nworld")).to_have_attribute("id", "label")
184-
expect(page.get_by_label("hello\nworld")).to_have_attribute("id", "control")
185-
expect(page.get_by_placeholder("hello\nworld")).to_have_attribute("id", "control")
186-
expect(page.get_by_alt_text("hello\nworld")).to_have_attribute("id", "control")
187-
expect(page.get_by_title("hello\nworld")).to_have_attribute("id", "control")
188+
expect(page.get_by_text("hello my\nworld")).to_have_attribute("id", "label")
189+
expect(page.get_by_text("hello my world")).to_have_attribute(
190+
"id", "label"
191+
)
192+
expect(page.get_by_label("hello my\nworld")).to_have_attribute("id", "control")
193+
expect(page.get_by_placeholder("hello my\nworld")).to_have_attribute(
194+
"id", "control"
195+
)
196+
expect(page.get_by_alt_text("hello my\nworld")).to_have_attribute("id", "control")
197+
expect(page.get_by_title("hello my\nworld")).to_have_attribute("id", "control")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy