(page: Page)
| 18 | |
| 19 | |
| 20 | async def test_get_by_escaping(page: Page) -> None: |
| 21 | await page.set_content( |
| 22 | """ |
| 23 | <label id=label for=control>Hello my |
| 24 | wo"rld</label><input id=control />""" |
| 25 | ) |
| 26 | await page.eval_on_selector( |
| 27 | "input", |
| 28 | """input => { |
| 29 | input.setAttribute('placeholder', 'hello my\\nwo"rld'); |
| 30 | input.setAttribute('title', 'hello my\\nwo"rld'); |
| 31 | input.setAttribute('alt', 'hello my\\nwo"rld'); |
| 32 | }""", |
| 33 | ) |
| 34 | await expect(page.get_by_text('hello my\nwo"rld')).to_have_attribute("id", "label") |
| 35 | await expect(page.get_by_text('hello my wo"rld')).to_have_attribute( |
| 36 | "id", "label" |
| 37 | ) |
| 38 | await expect(page.get_by_label('hello my\nwo"rld')).to_have_attribute( |
| 39 | "id", "control" |
| 40 | ) |
| 41 | await expect(page.get_by_placeholder('hello my\nwo"rld')).to_have_attribute( |
| 42 | "id", "control" |
| 43 | ) |
| 44 | await expect(page.get_by_alt_text('hello my\nwo"rld')).to_have_attribute( |
| 45 | "id", "control" |
| 46 | ) |
| 47 | await expect(page.get_by_title('hello my\nwo"rld')).to_have_attribute( |
| 48 | "id", "control" |
| 49 | ) |
| 50 | |
| 51 | await page.set_content( |
| 52 | """ |
| 53 | <label id=label for=control>Hello my |
| 54 | world</label><input id=control />""" |
| 55 | ) |
| 56 | await page.eval_on_selector( |
| 57 | "input", |
| 58 | """input => { |
| 59 | input.setAttribute('placeholder', 'hello my\\nworld'); |
| 60 | input.setAttribute('title', 'hello my\\nworld'); |
| 61 | input.setAttribute('alt', 'hello my\\nworld'); |
| 62 | }""", |
| 63 | ) |
| 64 | await expect(page.get_by_text("hello my\nworld")).to_have_attribute("id", "label") |
| 65 | await expect(page.get_by_text("hello my world")).to_have_attribute( |
| 66 | "id", "label" |
| 67 | ) |
| 68 | await expect(page.get_by_label("hello my\nworld")).to_have_attribute( |
| 69 | "id", "control" |
| 70 | ) |
| 71 | await expect(page.get_by_placeholder("hello my\nworld")).to_have_attribute( |
| 72 | "id", "control" |
| 73 | ) |
| 74 | await expect(page.get_by_alt_text("hello my\nworld")).to_have_attribute( |
| 75 | "id", "control" |
| 76 | ) |
| 77 | await expect(page.get_by_title("hello my\nworld")).to_have_attribute( |
nothing calls this directly
no test coverage detected