|
1 | 1 | package com.microsoft.playwright; |
2 | 2 |
|
| 3 | +import com.microsoft.playwright.assertions.LocatorAssertions; |
3 | 4 | import com.microsoft.playwright.options.AriaRole; |
4 | 5 | import org.junit.jupiter.api.Test; |
5 | 6 |
|
@@ -147,6 +148,11 @@ void getByEscaping() { |
147 | 148 | assertThat(page.getByPlaceholder("hello my\nworld")).hasAttribute("id", "control"); |
148 | 149 | assertThat(page.getByAltText("hello my\nworld")).hasAttribute("id", "control"); |
149 | 150 | assertThat(page.getByTitle("hello my\nworld")).hasAttribute("id", "control"); |
| 151 | + |
| 152 | + page.setContent("<div id=target title='my title'>Text here</div>"); |
| 153 | + assertThat(page.getByTitle("my title", new Page.GetByTitleOptions().setExact(true))).hasCount(1, new LocatorAssertions.HasCountOptions().setTimeout(500)); |
| 154 | + assertThat(page.getByTitle("my t\\itle", new Page.GetByTitleOptions().setExact(true))).hasCount(0, new LocatorAssertions.HasCountOptions().setTimeout(500)); |
| 155 | + assertThat(page.getByTitle("my t\\\\itle", new Page.GetByTitleOptions().setExact(true))).hasCount(0, new LocatorAssertions.HasCountOptions().setTimeout(500)); |
150 | 156 | } |
151 | 157 |
|
152 | 158 | @Test |
@@ -178,6 +184,16 @@ void getByRoleEscaping() { |
178 | 184 | assertEquals( |
179 | 185 | asList("<a href=\"https://playwright.dev\">he llo 56</a>"), |
180 | 186 | page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName(" he \n llo 56 ").setExact(true)).evaluateAll("els => els.map(e => e.outerHTML)")); |
| 187 | + |
| 188 | + assertEquals( |
| 189 | + asList("<button>Click me</button>"), |
| 190 | + page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Click me").setExact(true)).evaluateAll("els => els.map(e => e.outerHTML)")); |
| 191 | + assertEquals( |
| 192 | + asList(), |
| 193 | + page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Click \\me").setExact(true)).evaluateAll("els => els.map(e => e.outerHTML)")); |
| 194 | + assertEquals( |
| 195 | + asList(), |
| 196 | + page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Click \\\\me").setExact(true)).evaluateAll("els => els.map(e => e.outerHTML)")); |
181 | 197 | } |
182 | 198 |
|
183 | 199 | @Test |
|
0 commit comments