(page: Page)
| 152 | |
| 153 | |
| 154 | def test_get_by_escaping(page: Page) -> None: |
| 155 | page.set_content( |
| 156 | """<label id=label for=control>Hello my |
| 157 | wo"rld</label><input id=control />""" |
| 158 | ) |
| 159 | page.locator("input").evaluate( |
| 160 | """input => { |
| 161 | input.setAttribute('placeholder', 'hello my\\nwo"rld'); |
| 162 | input.setAttribute('title', 'hello my\\nwo"rld'); |
| 163 | input.setAttribute('alt', 'hello my\\nwo"rld'); |
| 164 | }""" |
| 165 | ) |
| 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") |
| 176 | |
| 177 | page.set_content( |
| 178 | """<label id=label for=control>Hello my |
| 179 | world</label><input id=control />""" |
| 180 | ) |
| 181 | page.locator("input").evaluate( |
| 182 | """input => { |
| 183 | input.setAttribute('placeholder', 'hello my\\nworld'); |
| 184 | input.setAttribute('title', 'hello my\\nworld'); |
| 185 | input.setAttribute('alt', 'hello my\\nworld'); |
| 186 | }""" |
| 187 | ) |
| 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") |
| 198 | |
| 199 | |
| 200 | def test_get_by_role(page: Page) -> None: |
nothing calls this directly
no test coverage detected