Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(assertions): note on whitespace normalization (#28110)

Yury Semikhatsky35aeace47616
diff --git a/docs/src/api/class-locatorassertions.md b/docs/src/api/class-locatorassertions.md
index 1569c69c2e..11244c0867 100644
--- a/docs/src/api/class-locatorassertions.md
+++ b/docs/src/api/class-locatorassertions.md
@@ -929,6 +929,11 @@ await Expect(
Ensures the [Locator] points to an element that contains the given text. You can use regular expressions for the value as well.
+**Details**
+
+When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
+in the expected string before matching. When regular expression is used, the actual text is matched as is.
+
**Usage**
```js
@@ -1598,6 +1603,11 @@ Note that screenshot assertions only work with Playwright test runner.
Ensures the [Locator] points to an element with the given text. You can use regular expressions for the value as well.
+**Details**
+
+When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual text and
+in the expected string before matching. When regular expression is used, the actual text is matched as is.
+
**Usage**
```js
diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts
index e605859592..78d89b89d1 100644
--- a/packages/playwright/types/test.d.ts
+++ b/packages/playwright/types/test.d.ts
@@ -5632,6 +5632,11 @@ interface LocatorAssertions {
* Ensures the {@link Locator} points to an element that contains the given text. You can use regular expressions for
* the value as well.
*
+ * **Details**
+ *
+ * When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
* **Usage**
*
* ```js
@@ -6029,6 +6034,11 @@ interface LocatorAssertions {
* Ensures the {@link Locator} points to an element with the given text. You can use regular expressions for the value
* as well.
*
+ * **Details**
+ *
+ * When `expected` parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
* **Usage**
*
* ```js