Skip to content

Commit f759222

Browse files
authored
fix: do not escape html symbols when serializing strings to json (#1005)
1 parent d87c6b2 commit f759222

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/Serialization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import static com.microsoft.playwright.impl.Utils.fromJsRegexFlags;
4141

4242
class Serialization {
43-
private static final Gson gson = new GsonBuilder()
43+
private static final Gson gson = new GsonBuilder().disableHtmlEscaping()
4444
.registerTypeAdapter(SameSiteAttribute.class, new SameSiteAdapter().nullSafe())
4545
.registerTypeAdapter(BrowserChannel.class, new ToLowerCaseAndDashSerializer<BrowserChannel>())
4646
.registerTypeAdapter(ColorScheme.class, new ToLowerCaseAndDashSerializer<ColorScheme>())

playwright/src/test/java/com/microsoft/playwright/TestPageLocatorQuery.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ void shouldFilterByRegexWithSpecialSymbols() {
139139
Pattern pattern = Pattern.compile("first\\/\".*\"second\\\\$", Pattern.CASE_INSENSITIVE);
140140
assertThat(page.locator("div", new Page.LocatorOptions().setHasText(pattern))).hasClass("test");
141141
}
142+
@Test
143+
void shouldFilterByTextWithAmpersand() {
144+
page.setContent("<div>Save & Continue</div>");
145+
assertEquals("Save & Continue", page.locator("div",
146+
new Page.LocatorOptions().setHasText("Save & Continue")).textContent());
147+
}
142148

143149
@Test
144150
void shouldSupportHasLocator() {

0 commit comments

Comments
 (0)