Skip to content

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

docs: split assertions list into langs (#19039)

Pavel Feldmanbe2139f0ac5b
diff --git a/docs/src/api/class-locatorassertions.md b/docs/src/api/class-locatorassertions.md
index 07f1b8ed52..cde7d64973 100644
--- a/docs/src/api/class-locatorassertions.md
+++ b/docs/src/api/class-locatorassertions.md
@@ -695,7 +695,7 @@ await Expect(locator).ToBeFocusedAsync();
* langs:
- alias-java: isHidden
-Ensures that [Locator] either does not resolve to any DOM node, or resolves to a [non-visible](./actionability.md#visible) one.
+Ensures that [Locator] either does not resolve to any DOM node, or resolves to a [non-visible](../actionability.md#visible) one.
**Usage**
@@ -738,7 +738,7 @@ await Expect(locator).ToBeHiddenAsync();
* langs:
- alias-java: isVisible
-Ensures that [Locator] points to an [attached](./actionability.md#attached) and [visible](./actionability.md#visible) DOM node.
+Ensures that [Locator] points to an [attached](../actionability.md#attached) and [visible](../actionability.md#visible) DOM node.
**Usage**
diff --git a/docs/src/api/class-screenshotassertions.md b/docs/src/api/class-screenshotassertions.md
index 1a2454d836..57cfd04545 100644
--- a/docs/src/api/class-screenshotassertions.md
+++ b/docs/src/api/class-screenshotassertions.md
@@ -33,7 +33,7 @@ expect(await page.screenshot()).toMatchSnapshot(['landing', 'step2.png']);
expect(await page.screenshot()).toMatchSnapshot(['landing', 'step3.png']);
```
-Learn more about [visual comparisons](./test-snapshots.md).
+Learn more about [visual comparisons](../test-snapshots.md).
### param: ScreenshotAssertions.toMatchSnapshot#1.name
* since: v1.22
@@ -73,7 +73,7 @@ expect(await page.screenshot()).toMatchSnapshot({
});
```
-Learn more about [visual comparisons](./test-snapshots.md).
+Learn more about [visual comparisons](../test-snapshots.md).
### option: ScreenshotAssertions.toMatchSnapshot#2.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.22
diff --git a/docs/src/test-assertions-csharp-java-python.md b/docs/src/test-assertions-csharp-java-python.md
new file mode 100644
index 0000000000..186d066bcc
--- /dev/null
+++ b/docs/src/test-assertions-csharp-java-python.md
@@ -0,0 +1,30 @@
+---
+id: test-assertions
+title: "Assertions"
+---
+
+## List of assertions
+
+| Assertion | Description |
+| :- | :- |
+| [`method: LocatorAssertions.toBeChecked`] | Checkbox is checked |
+| [`method: LocatorAssertions.toBeDisabled`] | Element is disabled |
+| [`method: LocatorAssertions.toBeEditable`] | Element is enabled |
+| [`method: LocatorAssertions.toBeEmpty`] | Container is empty |
+| [`method: LocatorAssertions.toBeEnabled`] | Element is enabled |
+| [`method: LocatorAssertions.toBeFocused`] | Element is focused |
+| [`method: LocatorAssertions.toBeHidden`] | Element is not visible |
+| [`method: LocatorAssertions.toBeVisible`] | Element is visible |
+| [`method: LocatorAssertions.toContainText`] | Element contains text |
+| [`method: LocatorAssertions.toHaveAttribute`] | Element has a DOM attribute |
+| [`method: LocatorAssertions.toHaveClass`] | Element has a class property |
+| [`method: LocatorAssertions.toHaveCount`] | List has exact number of children |
+| [`method: LocatorAssertions.toHaveCSS`] | Element has CSS property |
+| [`method: LocatorAssertions.toHaveId`] | Element has an ID |
+| [`method: LocatorAssertions.toHaveJSProperty`] | Element has a JavaScript property |
+| [`method: LocatorAssertions.toHaveText`] | Element matches text |
+| [`method: LocatorAssertions.toHaveValue`] | Input has a value |
+| [`method: LocatorAssertions.toHaveValues`] | Select has options selected |
+| [`method: PageAssertions.toHaveTitle`] | Page has a title |
+| [`method: PageAssertions.toHaveURL`] | Page has a URL |
+| [`method: APIResponseAssertions.toBeOK`] | Response has an OK status |
diff --git a/docs/src/test-assertions-js.md b/docs/src/test-assertions-js.md
index 00a417a601..88f2cc711d 100644
--- a/docs/src/test-assertions-js.md
+++ b/docs/src/test-assertions-js.md
@@ -20,6 +20,34 @@ Playwright Test will be re-testing the node with the selector `.status` until fe
By default, the timeout for assertions is set to 5 seconds. Learn more about [various timeouts](./test-timeouts.md).
+## List of assertions
+
+| Assertion | Description |
+| :- | :- |
+| [`method: LocatorAssertions.toBeChecked`] | Checkbox is checked |
+| [`method: LocatorAssertions.toBeDisabled`] | Element is disabled |
+| [`method: LocatorAssertions.toBeEditable`] | Element is enabled |
+| [`method: LocatorAssertions.toBeEmpty`] | Container is empty |
+| [`method: LocatorAssertions.toBeEnabled`] | Element is enabled |
+| [`method: LocatorAssertions.toBeFocused`] | Element is focused |
+| [`method: LocatorAssertions.toBeHidden`] | Element is not visible |
+| [`method: LocatorAssertions.toBeVisible`] | Element is visible |
+| [`method: LocatorAssertions.toContainText`] | Element contains text |
+| [`method: LocatorAssertions.toHaveAttribute`] | Element has a DOM attribute |
+| [`method: LocatorAssertions.toHaveClass`] | Element has a class property |
+| [`method: LocatorAssertions.toHaveCount`] | List has exact number of children |
+| [`method: LocatorAssertions.toHaveCSS`] | Element has CSS property |
+| [`method: LocatorAssertions.toHaveId`] | Element has an ID |
+| [`method: LocatorAssertions.toHaveJSProperty`] | Element has a JavaScript property |
+| [`method: LocatorAssertions.toHaveScreenshot#1`] | Element has a screenshot |
+| [`method: LocatorAssertions.toHaveText`] | Element matches text |
+| [`method: LocatorAssertions.toHaveValue`] | Input has a value |
+| [`method: LocatorAssertions.toHaveValues`] | Select has options selected |
+| [`method: PageAssertions.toHaveScreenshot#1`] | Page has a screenshot |
+| [`method: PageAssertions.toHaveTitle`] | Page has a title |
+| [`method: PageAssertions.toHaveURL`] | Page has a URL |
+| [`method: APIResponseAssertions.toBeOK`] | Response has an OK status |
+
## Negating Matchers
In general, we can expect the opposite to be true by adding a `.not` to the front
diff --git a/docs/src/writing-tests-js.md b/docs/src/writing-tests-js.md
index 5fa7d073b3..2d94474c44 100644
--- a/docs/src/writing-tests-js.md
+++ b/docs/src/writing-tests-js.md
@@ -134,7 +134,6 @@ Here is the list of the most popular async assertions. Note that there are [many
| Assertion | Description |
| :- | :- |
| [`method: LocatorAssertions.toBeChecked`] | Checkbox is checked |
-| [`method: LocatorAssertions.toBeChecked`] | Checkbox is checked |
| [`method: LocatorAssertions.toBeEnabled`] | Control is enabled |
| [`method: LocatorAssertions.toBeVisible`] | Element is visible |
| [`method: LocatorAssertions.toContainText`] | Element contains text |
diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts
index 1d17346a89..7ca345939c 100644
--- a/packages/playwright-test/types/test.d.ts
+++ b/packages/playwright-test/types/test.d.ts
@@ -3567,7 +3567,7 @@ interface LocatorAssertions {
/**
* Ensures that [Locator] either does not resolve to any DOM node, or resolves to a
- * [non-visible](https://playwright.dev/docs/api/actionability#visible) one.
+ * [non-visible](https://playwright.dev/docs/actionability#visible) one.
*
* **Usage**
*
@@ -3586,8 +3586,8 @@ interface LocatorAssertions {
}): Promise<void>;
/**
- * Ensures that [Locator] points to an [attached](https://playwright.dev/docs/api/actionability#attached) and
- * [visible](https://playwright.dev/docs/api/actionability#visible) DOM node.
+ * Ensures that [Locator] points to an [attached](https://playwright.dev/docs/actionability#attached) and
+ * [visible](https://playwright.dev/docs/actionability#visible) DOM node.
*
* **Usage**
*
@@ -4392,7 +4392,7 @@ interface ScreenshotAssertions {
* expect(await page.screenshot()).toMatchSnapshot(['landing', 'step3.png']);
* ```
*
- * Learn more about [visual comparisons](https://playwright.dev/docs/api/test-snapshots).
+ * Learn more about [visual comparisons](https://playwright.dev/docs/test-snapshots).
* @param name Snapshot name.
* @param options
*/
@@ -4439,7 +4439,7 @@ interface ScreenshotAssertions {
* });
* ```
*
- * Learn more about [visual comparisons](https://playwright.dev/docs/api/test-snapshots).
+ * Learn more about [visual comparisons](https://playwright.dev/docs/test-snapshots).
* @param options
*/
toMatchSnapshot(options?: {
diff --git a/utils/doclint/cli.js b/utils/doclint/cli.js
index 57924b87a4..0a54c831c5 100755
--- a/utils/doclint/cli.js
+++ b/utils/doclint/cli.js
@@ -206,24 +206,11 @@ async function run() {
if (mdLink.startsWith('#'))
continue;
- // The assertion classes are "virtual files" which get merged into test-assertions.md inside our docs generator
let markdownBasePath = path.dirname(filePath);
- if ([
- 'class-screenshotassertions.md',
- 'class-locatorassertions.md',
- 'class-pageassertions.md'
- ].includes(path.basename(filePath))) {
- markdownBasePath = documentationRoot;
- }
-
let linkWithoutHash = path.join(markdownBasePath, mdLink.split('#')[0]);
if (path.extname(linkWithoutHash) !== '.md')
linkWithoutHash += '.md';
- // We generate it inside the generator (playwright.dev)
- if (path.basename(linkWithoutHash) === 'test-assertions.md')
- return;
-
if (!relevantMarkdownFiles.has(linkWithoutHash))
throw new Error(`${path.relative(PROJECT_DIR, filePath)} references to '${linkWithoutHash}' as '${mdLinkName}' which does not exist.`);
}