Skip to content

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

chore: validate markdown links in doclint (#24444)

Dmitry Gozmanc8b45aa844a7
diff --git a/docs/src/accessibility-testing-js.md b/docs/src/accessibility-testing-js.md
index e806a1aeb5..10e8fe30a3 100644
--- a/docs/src/accessibility-testing-js.md
+++ b/docs/src/accessibility-testing-js.md
@@ -95,7 +95,7 @@ By default, axe checks against a wide variety of accessibility rules. Some of th
You can constrain an accessibility scan to only run those rules which are "tagged" as corresponding to specific WCAG success criteria by using [`AxeBuilder.withTags()`](https://github.com/dequelabs/axe-core-npm/blob/develop/packages/playwright/README.md#axebuilderwithtagstags-stringarray). For example, [Accessibility Insights for Web's Automated Checks](https://accessibilityinsights.io/docs/web/getstarted/fastpass/?referrer=playwright-accessibility-testing-js) only include axe rules that test for violations of WCAG A and AA success criteria; to match that behavior, you would use the tags `wcag2a`, `wcag2aa`, `wcag21a`, and `wcag21aa`.
-Note that [automated testing cannot detect all types of WCAG violations](#disclaimer).
+Note that automated testing cannot detect all types of WCAG violations.
```js
test('should not have any automatically detectable WCAG A or AA violations', async ({ page }) => {
diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md
index 63e93a146c..307407f4ca 100644
--- a/docs/src/api/class-browsercontext.md
+++ b/docs/src/api/class-browsercontext.md
@@ -1190,7 +1190,7 @@ How often a route should be used. By default it will be used every time.
## async method: BrowserContext.routeFromHAR
* since: v1.23
-If specified the network requests that are made in the context will be served from the HAR file. Read more about [Replaying from HAR](../network.md#replaying-from-har).
+If specified the network requests that are made in the context will be served from the HAR file. Read more about [Replaying from HAR](../mock.md#replaying-from-har).
Playwright will not serve requests intercepted by Service Worker from the HAR file. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting [`option: Browser.newContext.serviceWorkers`] to `'block'`.
diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md
index e9635de2af..bbf3446417 100644
--- a/docs/src/api/class-page.md
+++ b/docs/src/api/class-page.md
@@ -3320,7 +3320,7 @@ How often a route should be used. By default it will be used every time.
## async method: Page.routeFromHAR
* since: v1.23
-If specified the network requests that are made in the page will be served from the HAR file. Read more about [Replaying from HAR](../network.md#replaying-from-har).
+If specified the network requests that are made in the page will be served from the HAR file. Read more about [Replaying from HAR](../mock.md#replaying-from-har).
Playwright will not serve requests intercepted by Service Worker from the HAR file. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting [`option: Browser.newContext.serviceWorkers`] to `'block'`.
diff --git a/docs/src/api/params.md b/docs/src/api/params.md
index d1c55f3e28..81fa010aee 100644
--- a/docs/src/api/params.md
+++ b/docs/src/api/params.md
@@ -307,7 +307,7 @@ When using [`method: Page.goto`], [`method: Page.route`], [`method: Page.waitFor
- `width` <[int]> page width in pixels.
- `height` <[int]> page height in pixels.
-Emulates consistent viewport for each page. Defaults to an 1280x720 viewport.
+Emulates consistent viewport for each page. Defaults to an 1280x720 viewport.
Use `null` to disable the consistent viewport emulation. Learn more about [viewport emulation](../emulation#viewport).
:::note
@@ -510,7 +510,7 @@ Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn m
## context-option-ismobile
- `isMobile` <[boolean]>
-Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation](../emulation.md#isMobile).
+Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation](../emulation.md#ismobile).
## context-option-hastouch
- `hasTouch` <[boolean]>
diff --git a/docs/src/best-practices-js.md b/docs/src/best-practices-js.md
index 85068d1184..53dc975443 100644
--- a/docs/src/best-practices-js.md
+++ b/docs/src/best-practices-js.md
@@ -38,13 +38,13 @@ test('second', async ({ page }) => {
});
```
-You can also reuse the signed-in state in the tests with [global setup](/auth.md#reuse-signed-in-state). That way you can log in only once and then skip the log in step for all of the tests.
+You can also reuse the signed-in state in the tests with [setup project](./auth.md#basic-shared-account-in-all-tests). That way you can log in only once and then skip the log in step for all of the tests.
### Avoid testing third-party dependencies
Only test what you control. Don't try to test links to external sites or third party servers that you do not control. Not only is it time consuming and can slow down your tests but also you can not control the content of the page you are linking to, or if there are cookie banners or overlay pages or anything else that might cause your test to fail.
-Instead, use the [Playwright Network API](/network.md#handle-requests) and guarantee the response needed.
+Instead, use the [Playwright Network API](/network.md#handle-requests) and guarantee the response needed.
```js
await page.route('**/api/fetch_data_third_party_dependency', route => route.fulfill({
@@ -71,7 +71,7 @@ page.getByRole('button', { name: 'submit' });
#### Use chaining and filtering
-Locators can be [chained](./locators.md#chaining-locators) to narrow down the search to a particular part of the page.
+Locators can be [chained](./locators.md#matching-inside-a-locator) to narrow down the search to a particular part of the page.
```js
const product = page.getByRole('listitem').filter({ hasText: 'Product 2' });
@@ -217,7 +217,7 @@ Playwright comes with a range of tooling to help you write tests.
### Test across all browsers
-Playwright makes it easy to test your site across all [browsers](./test-configuration#multiple-browsers) no matter what platform you are on. Testing across all browsers ensures your app works for all users. In your config file you can set up projects adding the name and which browser or device to use.
+Playwright makes it easy to test your site across all [browsers](./test-projects.md#configure-projects-for-multiple-browsers) no matter what platform you are on. Testing across all browsers ensures your app works for all users. In your config file you can set up projects adding the name and which browser or device to use.
```js title="playwright.config.ts"
import { defineConfig, devices } from '@playwright/test';
diff --git a/docs/src/codegen-intro.md b/docs/src/codegen-intro.md
index 6532174140..82d44fe90d 100644
--- a/docs/src/codegen-intro.md
+++ b/docs/src/codegen-intro.md
@@ -8,7 +8,7 @@ Playwright comes with the ability to generate tests out of the box and is a grea
**You will learn**
- [How to record a test](/codegen.md#recording-a-test)
-- [How to generate locators](/codegen.md#generate-locators)
+- [How to generate locators](/codegen.md#generating-locators)
<video width="100%" height="100%" controls muted >
<source src="https://user-images.githubusercontent.com/13063165/197979804-c4fa3347-8fab-4526-a728-c1b2fbd079b4.mp4" type="video/mp4" />
@@ -67,10 +67,10 @@ To learn more about generating tests check out or detailed guide on [Codegen](./
### Generating locators
-You can generate [locators](/locators.md) with the test generator.
+You can generate [locators](/locators.md) with the test generator.
* Press the `'Record'` button to stop the recording and the `'Pick Locator'` button will appear.
-* Click on the `'Pick Locator'` button and then hover over elements in the browser window to see the locator highlighted underneath each element.
+* Click on the `'Pick Locator'` button and then hover over elements in the browser window to see the locator highlighted underneath each element.
* To choose a locator click on the element you would like to locate and the code for that locator will appear in the field next to the Pick Locator button.
* You can then edit the locator in this field to fine tune it or use the copy button to copy it and paste it into your code.
diff --git a/docs/src/emulation.md b/docs/src/emulation.md
index 29c9471702..9dc17f34c8 100644
--- a/docs/src/emulation.md
+++ b/docs/src/emulation.md
@@ -8,7 +8,7 @@ With Playwright you can test your app on any browser as well as emulate a real d
## Devices
* langs: js, csharp, python
-Playwright comes with a [registry of device parameters](https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json) using [`property: Playwright.devices`] for selected desktop, tablet and mobile devices. It can be used to simulate browser behavior for a specific device such as user agent, screen size, viewport and if it has touch enabled. All tests will run with the specified device parameters.
+Playwright comes with a [registry of device parameters](https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json) using [`property: Playwright.devices`] for selected desktop, tablet and mobile devices. It can be used to simulate browser behavior for a specific device such as user agent, screen size, viewport and if it has touch enabled. All tests will run with the specified device parameters.
```js tab=js-test title="playwright.config.ts"
import { defineConfig, devices } from '@playwright/test'; // import devices
@@ -88,6 +88,12 @@ await using var context = await browser.NewContextAsync(iphone13);
<img width="458" alt="playwright.dev website emulated for iPhone 13" src="https://user-images.githubusercontent.com/13063165/220411073-76fe59f9-9a2d-463d-8e30-c19a7deca133.png" />
+
+## Devices
+* langs: java
+
+Playwright can emulate various devices by specifying `setDeviceScaleFactor`, `setHasTouch`, `setIsMobile`, `setScreenSize`, `setUserAgent` and `setViewportSize` options when creating a context with [`method: Browser.newContext`].
+
## Viewport
The viewport is included in the device but you can override it for some tests with [`method: Page.setViewportSize`].
diff --git a/docs/src/intro-java.md b/docs/src/intro-java.md
index 2a4bd38382..fa6c5b6c60 100644
--- a/docs/src/intro-java.md
+++ b/docs/src/intro-java.md
@@ -86,7 +86,7 @@ With the Example.java and pom.xml above, compile and execute your new program as
mvn compile exec:java -D exec.mainClass="org.example.App"
```
-Running it downloads the Playwright package and installs browser binaries for Chromium, Firefox and WebKit. To modify this behavior see [installation parameters](./browsers.md#installing-browsers).
+Running it downloads the Playwright package and installs browser binaries for Chromium, Firefox and WebKit. To modify this behavior see [installation parameters](./browsers.md#install-browsers).
## First script
diff --git a/docs/src/library-js.md b/docs/src/library-js.md
index ba54b90951..c317929f99 100644
--- a/docs/src/library-js.md
+++ b/docs/src/library-js.md
@@ -113,7 +113,7 @@ In addition to the above, Playwright Test, as a full-featured Test Runner, inclu
- [Web-First Assertions](./test-assertions.md)
- [Reporting](./test-reporters.md)
- [Retries](./test-retries.md)
-- [Easily Enabled Tracing](./test-configuration.md#record-test-trace)
+- [Easily Enabled Tracing](./trace-viewer-intro.md)
- and more…
## Usage
diff --git a/docs/src/library-python.md b/docs/src/library-python.md
index d14b846576..8391ea92ef 100644
--- a/docs/src/library-python.md
+++ b/docs/src/library-python.md
@@ -26,7 +26,7 @@ conda install playwright
playwright install
```
-These commands download the Playwright package and install browser binaries for Chromium, Firefox and WebKit. To modify this behavior see [installation parameters](./browsers.md#installing-browsers).
+These commands download the Playwright package and install browser binaries for Chromium, Firefox and WebKit. To modify this behavior see [installation parameters](./browsers.md#install-browsers).
## Usage
diff --git a/docs/src/other-locators.md b/docs/src/other-locators.md
index 73f9f1f1b4..f50b986228 100644
--- a/docs/src/other-locators.md
+++ b/docs/src/other-locators.md
@@ -888,7 +888,7 @@ Attribute selectors pierce shadow DOM. To opt-out from this behavior, use `:ligh
## Chaining selectors
:::warning
-We recommend [chaining locators](./locators.md#chaining-locators) instead.
+We recommend [chaining locators](./locators.md#matching-inside-a-locator) instead.
:::
Selectors defined as `engine=body` or in short-form can be combined with the `>>` token, e.g. `selector1 >> selector2 >> selectors3`. When selectors are chained, the next one is queried relative to the previous one's result.
diff --git a/docs/src/protractor-js.md b/docs/src/protractor-js.md
index 254a746a5f..723974ff4d 100644
--- a/docs/src/protractor-js.md
+++ b/docs/src/protractor-js.md
@@ -149,12 +149,12 @@ Once you're on Playwright Test, you get a lot!
- Run tests across **all web engines** (Chrome, Firefox, Safari) on **any popular operating system** (Windows, macOS, Ubuntu)
- Full support for multiple origins, [(i)frames](./api/class-frame), [tabs and contexts](./pages)
- Run tests in parallel across multiple browsers
-- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
+- Built-in test [artifact collection](./test-use-options.md#recording-options)
You also get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
- [Playwright Inspector](./debug.md)
-- [Playwright Test Code generation](./auth#code-generation)
-- [Playwright Tracing](./trace-viewer) for post-mortem debugging
+- [Playwright Test Code generation](./codegen-intro.md)
+- [Playwright Tracing](./trace-viewer.md) for post-mortem debugging
## Further Reading
diff --git a/docs/src/puppeteer-js.md b/docs/src/puppeteer-js.md
index b3ac2ca1f8..e264907688 100644
--- a/docs/src/puppeteer-js.md
+++ b/docs/src/puppeteer-js.md
@@ -157,12 +157,12 @@ Once you're on Playwright Test, you get a lot!
- Run tests across **all web engines** (Chrome, Firefox, Safari) on **any popular operating system** (Windows, macOS, Ubuntu)
- Full support for multiple origins, [(i)frames](./api/class-frame), [tabs and contexts](./pages)
- Run tests in isolation in parallel across multiple browsers
-- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
+- Built-in test [artifact collection](./test-use-options.md#recording-options)
You also get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
- [Playwright Inspector](./debug.md)
-- [Playwright Test Code generation](./auth#code-generation)
-- [Playwright Tracing](./trace-viewer) for post-mortem debugging
+- [Playwright Test Code generation](./codegen-intro.md)
+- [Playwright Tracing](./trace-viewer.md) for post-mortem debugging
## Further Reading
diff --git a/docs/src/release-notes-csharp.md b/docs/src/release-notes-csharp.md
index 71b8b2c92c..3ed66a102a 100644
--- a/docs/src/release-notes-csharp.md
+++ b/docs/src/release-notes-csharp.md
@@ -127,7 +127,7 @@ This version was also tested against the following stable channels:
### New APIs
- New options [`option: updateMode`] and [`option: updateContent`] in [`method: Page.routeFromHAR`] and [`method: BrowserContext.routeFromHAR`].
-- Chaining existing locator objects, see [locator docs](./locators.md#chaining-locators) for details.
+- Chaining existing locator objects, see [locator docs](./locators.md#matching-inside-a-locator) for details.
- New option [`option: name`] in method [`method: Tracing.startChunk`].
### Browser Versions
@@ -497,7 +497,7 @@ Use the new methods [`method: Page.routeFromHAR`] or [`method: BrowserContext.ro
await context.RouteFromHARAsync("example.har");
```
-Read more in [our documentation](./network#record-and-replay-requests).
+Read more in [our documentation](./mock.md#mocking-with-har-files).
### Advanced Routing
@@ -676,7 +676,7 @@ This version was also tested against the following stable channels:
await Page.Locator("article", new() { Has = Page.Locator(".highlight") }).ClickAsync();
```
- Read more in [locator documentation](./api/class-locator#locator-locator-option-has)
+ Read more in [locator documentation](./api/class-locator#locator-locator)
- New [`method: Locator.page`]
- [`method: Page.screenshot`] and [`method: Locator.screenshot`] now automatically hide blinking caret
@@ -704,7 +704,7 @@ This version was also tested against the following stable channels:
await Page.Locator("li", new() { HasTextString = "My Item" })
.Locator("button").click();
```
- Read more in [locator documentation](./api/class-locator#locator-locator-option-has-text)
+ Read more in [locator documentation](./api/class-locator#locator-locator)
### New APIs & changes
diff --git a/docs/src/release-notes-java.md b/docs/src/release-notes-java.md
index 35328d20e0..92e2bacdcb 100644
--- a/docs/src/release-notes-java.md
+++ b/docs/src/release-notes-java.md
@@ -141,7 +141,7 @@ This version was also tested against the following stable channels:
### New APIs
- New options [`option: updateMode`] and [`option: updateContent`] in [`method: Page.routeFromHAR`] and [`method: BrowserContext.routeFromHAR`].
-- Chaining existing locator objects, see [locator docs](./locators.md#chaining-locators) for details.
+- Chaining existing locator objects, see [locator docs](./locators.md#matching-inside-a-locator) for details.
- New option [`option: name`] in method [`method: Tracing.startChunk`].
### Browser Versions
@@ -449,7 +449,7 @@ Use the new methods [`method: Page.routeFromHAR`] or [`method: BrowserContext.ro
context.routeFromHAR(Paths.get("example.har"));
```
-Read more in [our documentation](./network#record-and-replay-requests).
+Read more in [our documentation](./mock.md#mocking-with-har-files).
### Advanced Routing
@@ -597,7 +597,7 @@ This version was also tested against the following stable channels:
page.locator("article", new Page.LocatorOptions().setHas(page.locator(".highlight"))).click();
```
- Read more in [locator documentation](./api/class-locator#locator-locator-option-has)
+ Read more in [locator documentation](./api/class-locator#locator-locator)
- New [`method: Locator.page`]
- [`method: Page.screenshot`] and [`method: Locator.screenshot`] now automatically hide blinking caret
@@ -670,7 +670,7 @@ Read more in [our documentation](./test-assertions).
page.locator("li", new Page.LocatorOptions().setHasText("my item"))
.locator("button").click();
```
- Read more in [locator documentation](./api/class-locator#locator-locator-option-has-text)
+ Read more in [locator documentation](./api/class-locator#locator-locator)
### Tracing Improvements
diff --git a/docs/src/release-notes-js.md b/docs/src/release-notes-js.md
index 3af86bd451..a91cb82e15 100644
--- a/docs/src/release-notes-js.md
+++ b/docs/src/release-notes-js.md
@@ -268,7 +268,7 @@ npx playwright test --ui
### New APIs
- New options [`option: updateMode`] and [`option: updateContent`] in [`method: Page.routeFromHAR`] and [`method: BrowserContext.routeFromHAR`].
-- Chaining existing locator objects, see [locator docs](./locators.md#chaining-locators) for details.
+- Chaining existing locator objects, see [locator docs](./locators.md#matching-inside-a-locator) for details.
- New property [`property: TestInfo.testId`].
- New option [`option: name`] in method [`method: Tracing.startChunk`].
@@ -469,7 +469,7 @@ This version was also tested against the following stable channels:
}).toPass();
```
- Read more in [our documentation](./test-assertions.md#retrying).
+ Read more in [our documentation](./test-assertions.md#expecttopass).
- Automatically capture **full page screenshot** on test failure:
```js title="playwright.config.ts"
@@ -894,7 +894,7 @@ Use the new methods [`method: Page.routeFromHAR`] or [`method: BrowserContext.ro
await context.routeFromHAR('github.har.zip');
```
-Read more in [our documentation](./network#record-and-replay-requests).
+Read more in [our documentation](./mock.md#mocking-with-har-files).
### Advanced Routing
@@ -1081,7 +1081,7 @@ WebServer is now considered "ready" if request to the specified url has any of t
```
`expect.poll` supports most synchronous matchers, like `.toBe()`, `.toContain()`, etc.
- Read more in [our documentation](./test-assertions.md#polling).
+ Read more in [our documentation](./test-assertions.md#expectpoll).
### Behavior Changes
@@ -1220,7 +1220,7 @@ This version was also tested against the following stable channels:
6 |
```
- Read more in [our documentation](./test-assertions#custom-error-message)
+ Read more in [our documentation](./test-assertions#custom-expect-message)
- By default, tests in a single file are run in order. If you have many independent tests in a single file, you can now
run them in parallel with [`method: Test.describe.configure`].
@@ -1234,7 +1234,7 @@ This version was also tested against the following stable channels:
}).click();
```
- Read more in [locator documentation](./api/class-locator#locator-locator-option-has)
+ Read more in [locator documentation](./api/class-locator#locator-locator)
- New [`method: Locator.page`]
- [`method: Page.screenshot`] and [`method: Locator.screenshot`] now automatically hide blinking caret
@@ -1276,7 +1276,7 @@ This version was also tested against the following stable channels:
```js
await page.locator('li', { hasText: 'my item' }).locator('button').click();
```
- Read more in [locator documentation](./api/class-locator#locator-locator-option-has-text)
+ Read more in [locator documentation](./api/class-locator#locator-locator)
### Testing API improvements
diff --git a/docs/src/release-notes-python.md b/docs/src/release-notes-python.md
index 557867e4d4..33be07c97b 100644
--- a/docs/src/release-notes-python.md
+++ b/docs/src/release-notes-python.md
@@ -127,7 +127,7 @@ This version was also tested against the following stable channels:
- Custom expect message, see [test assertions documentation](./test-assertions.md#custom-expect-message).
- New options [`option: updateMode`] and [`option: updateContent`] in [`method: Page.routeFromHAR`] and [`method: BrowserContext.routeFromHAR`].
-- Chaining existing locator objects, see [locator docs](./locators.md#chaining-locators) for details.
+- Chaining existing locator objects, see [locator docs](./locators.md#matching-inside-a-locator) for details.
- New option [`option: name`] in method [`method: Tracing.startChunk`].
### Browser Versions
@@ -450,7 +450,7 @@ await context.route_from_har("github.har.zip")
context.route_from_har("github.har.zip")
```
-Read more in [our documentation](./network#record-and-replay-requests).
+Read more in [our documentation](./mock.md#mocking-with-har-files).
### Advanced Routing
@@ -651,7 +651,7 @@ This version was also tested against the following stable channels:
page.locator("article", has=page.locator(".highlight")).click()
```
- Read more in [locator documentation](./api/class-locator#locator-locator-option-has)
+ Read more in [locator documentation](./api/class-locator#locator-locator)
- New [`method: Locator.page`]
- [`method: Page.screenshot`] and [`method: Locator.screenshot`] now automatically hide blinking caret
@@ -737,7 +737,7 @@ Read more in [our documentation](./test-assertions).
page.locator("li", has_text="my item").locator("button").click()
```
- Read more in [locator documentation](./api/class-locator#locator-locator-option-has-text)
+ Read more in [locator documentation](./api/class-locator#locator-locator)
### New APIs & changes
diff --git a/docs/src/selenium-grid.md b/docs/src/selenium-grid.md
index b4fc5e23b2..41138d66ce 100644
--- a/docs/src/selenium-grid.md
+++ b/docs/src/selenium-grid.md
@@ -52,8 +52,6 @@ SELENIUM_REMOTE_URL=http://<selenium-hub-ip>:4444 dotnet test
You don't have to change your code, just use your testing harness or [`method: BrowserType.launch`] as usual.
-When using Selenium Grid Hub, you can [skip browser downloads](./browsers.md#skip-browser-downloads).
-
### Passing additional capabilities
If your grid requires additional capabilities to be set (for example, you use an external service), you can set `SELENIUM_REMOTE_CAPABILITIES` environment variable to provide JSON-serialized capabilities.
diff --git a/docs/src/test-api/class-testoptions.md b/docs/src/test-api/class-testoptions.md
index 763d18057d..1515e1656d 100644
--- a/docs/src/test-api/class-testoptions.md
+++ b/docs/src/test-api/class-testoptions.md
@@ -475,7 +475,7 @@ export default defineConfig({
});
```
-Learn more about [automatic screenshots](../test-configuration.md#automatic-screenshots).
+Learn more about [automatic screenshots](../test-use-options.md#recording-options).
## property: TestOptions.storageState = %%-js-python-context-option-storage-state-%%
* since: v1.10
@@ -554,7 +554,7 @@ export default defineConfig({
});
```
-Learn more about [recording trace](../test-configuration.md#record-test-trace).
+Learn more about [recording trace](../test-use-options.md#recording-options).
## property: TestOptions.userAgent = %%-context-option-useragent-%%
* since: v1.10
@@ -599,7 +599,7 @@ export default defineConfig({
});
```
-Learn more about [recording video](../test-configuration.md#record-video).
+Learn more about [recording video](../test-use-options.md#recording-options).
## property: TestOptions.viewport = %%-context-option-viewport-%%
* since: v1.10
diff --git a/docs/src/test-global-setup-teardown-js.md b/docs/src/test-global-setup-teardown-js.md
index 566db50488..4ee6479247 100644
--- a/docs/src/test-global-setup-teardown-js.md
+++ b/docs/src/test-global-setup-teardown-js.md
@@ -174,7 +174,7 @@ Start by creating a `global.setup.ts` file at the root level of your project. Th
```js title="global.setup.ts"
// seed the database with some data
```
-Then create a `global.teardown.ts` file at the root level of your project. This will be used to delete the data from the database after all tests have run.
+Then create a `global.teardown.ts` file at the root level of your project. This will be used to delete the data from the database after all tests have run.
```js title="global.teardown.ts"
// delete the data from the database
@@ -212,7 +212,7 @@ export default defineConfig({
## Configure globalSetup and globalTeardown
-You can use the `globalSetup` option in the [configuration file](#configuration-object) to set something up once before running all tests. The global setup file must export a single function that takes a config object. This function will be run once before all the tests.
+You can use the `globalSetup` option in the [configuration file](./test-configuration.md#advanced-configuration) to set something up once before running all tests. The global setup file must export a single function that takes a config object. This function will be run once before all the tests.
Similarly, use `globalTeardown` to run something once after all the tests. Alternatively, let `globalSetup` return a function that will be used as a global teardown. You can pass data such as port number, authentication tokens, etc. from your global setup to your tests using environment variables.
diff --git a/docs/src/test-snapshots-js.md b/docs/src/test-snapshots-js.md
index df824b339d..bbbdb16991 100644
--- a/docs/src/test-snapshots-js.md
+++ b/docs/src/test-snapshots-js.md
@@ -57,7 +57,7 @@ npx playwright test --update-snapshots
> Note that `snapshotName` also accepts an array of path segments to the snapshot file such as `expect().toHaveScreenshot(['relative', 'path', 'to', 'snapshot.png'])`.
> However, this path must stay within the snapshots directory for each test file (i.e. `a.spec.js-snapshots`), otherwise it will throw.
-Playwright Test uses the [pixelmatch](https://github.com/mapbox/pixelmatch) library. You can [pass various options](./test-assertions#page-assertions-to-have-screenshot-2) to modify its behavior:
+Playwright Test uses the [pixelmatch](https://github.com/mapbox/pixelmatch) library. You can [pass various options](./api/class-pageassertions.md#page-assertions-to-have-screenshot-1) to modify its behavior:
```js title="example.spec.ts"
import { test, expect } from '@playwright/test';
diff --git a/docs/src/test-use-options-js.md b/docs/src/test-use-options-js.md
index fa9f9a1652..9912b35dc9 100644
--- a/docs/src/test-use-options-js.md
+++ b/docs/src/test-use-options-js.md
@@ -106,7 +106,7 @@ export default defineConfig({
},
});
```
-
+
| Option | Description |
| :- | :- |
| [`property: TestOptions.acceptDownloads`] | Whether to automatically download all the attachments, defaults to `true`. [Learn more](./downloads.md) about working with downloads. |
@@ -123,7 +123,7 @@ You don't have to configure anything to mock network requests. Just define a cus
### Recording Options
-With Playwright you can capture screenshots, record videos as well as traces of your test. By default these are turned off but you can enable them by setting the `screenshot`, `video` and `trace` options in your `playwright.config.js` file.
+With Playwright you can capture screenshots, record videos as well as traces of your test. By default these are turned off but you can enable them by setting the `screenshot`, `video` and `trace` options in your `playwright.config.js` file.
Trace files, screenshots and videos will appear in the test output directory, typically `test-results`.
@@ -143,7 +143,7 @@ export default defineConfig({
},
});
```
-
+
| Option | Description |
| :- | :- |
| [`property: TestOptions.screenshot`] | Capture [screenshots](./screenshots.md) of your test. Options include `'off'`, `'on'` and `'only-on-failure'` |
@@ -204,7 +204,7 @@ export default defineConfig({
});
```
-However, most common ones like `headless` or `viewport` are available directly in the `use` section - see [basic options](#basic-options), [emulation](./emulation.md) or [network](#network).
+However, most common ones like `headless` or `viewport` are available directly in the `use` section - see [basic options](#basic-options), [emulation](#emulation-options) or [network](#network-options).
### Explicit Context Creation and Option Inheritance
diff --git a/docs/src/testing-library-js.md b/docs/src/testing-library-js.md
index b84fe65ec4..7748209bfd 100644
--- a/docs/src/testing-library-js.md
+++ b/docs/src/testing-library-js.md
@@ -132,12 +132,12 @@ Once you're on Playwright Test, you get a lot!
- Run tests across **all web engines** (Chrome, Firefox, Safari) on **any popular operating system** (Windows, macOS, Ubuntu)
- Full support for multiple origins, [(i)frames](./api/class-frame), [tabs and contexts](./pages)
- Run tests in isolation in parallel across multiple browsers
-- Built-in test artifact collection: [video recording](./test-configuration#record-video), [screenshots](./test-configuration#automatic-screenshots) and [playwright traces](./test-configuration#record-test-trace)
+- Built-in test [artifact collection](./test-use-options.md#recording-options)
You also get all these ✨ awesome tools ✨ that come bundled with Playwright Test:
- [Playwright Inspector](./debug.md)
-- [Playwright Test Code generation](./auth#code-generation)
-- [Playwright Tracing](./trace-viewer) for post-mortem debugging
+- [Playwright Test Code generation](./codegen-intro.md)
+- [Playwright Tracing](./trace-viewer.md) for post-mortem debugging
## Further Reading
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index 70ea53f396..23310705a5 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -3600,7 +3600,7 @@ export interface Page {
/**
* If specified the network requests that are made in the page will be served from the HAR file. Read more about
- * [Replaying from HAR](https://playwright.dev/docs/network#replaying-from-har).
+ * [Replaying from HAR](https://playwright.dev/docs/mock#replaying-from-har).
*
* Playwright will not serve requests intercepted by Service Worker from the HAR file. See
* [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when
@@ -8327,7 +8327,7 @@ export interface BrowserContext {
/**
* If specified the network requests that are made in the context will be served from the HAR file. Read more about
- * [Replaying from HAR](https://playwright.dev/docs/network#replaying-from-har).
+ * [Replaying from HAR](https://playwright.dev/docs/mock#replaying-from-har).
*
* Playwright will not serve requests intercepted by Service Worker from the HAR file. See
* [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when
@@ -12738,7 +12738,7 @@ export interface BrowserType<Unused = {}> {
/**
* Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more
- * about [mobile emulation](https://playwright.dev/docs/emulation#isMobile).
+ * about [mobile emulation](https://playwright.dev/docs/emulation#ismobile).
*/
isMobile?: boolean;
@@ -12959,7 +12959,7 @@ export interface BrowserType<Unused = {}> {
videosPath?: string;
/**
- * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
+ * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
* viewport emulation. Learn more about [viewport emulation](https://playwright.dev/docs/emulation#viewport).
*
* **NOTE** The `null` value opts out from the default presets, makes viewport depend on the host window size defined
@@ -14145,7 +14145,7 @@ export interface AndroidDevice {
/**
* Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more
- * about [mobile emulation](https://playwright.dev/docs/emulation#isMobile).
+ * about [mobile emulation](https://playwright.dev/docs/emulation#ismobile).
*/
isMobile?: boolean;
@@ -14349,7 +14349,7 @@ export interface AndroidDevice {
videosPath?: string;
/**
- * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
+ * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
* viewport emulation. Learn more about [viewport emulation](https://playwright.dev/docs/emulation#viewport).
*
* **NOTE** The `null` value opts out from the default presets, makes viewport depend on the host window size defined
@@ -16020,7 +16020,7 @@ export interface Browser extends EventEmitter {
/**
* Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more
- * about [mobile emulation](https://playwright.dev/docs/emulation#isMobile).
+ * about [mobile emulation](https://playwright.dev/docs/emulation#ismobile).
*/
isMobile?: boolean;
@@ -16284,7 +16284,7 @@ export interface Browser extends EventEmitter {
videosPath?: string;
/**
- * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
+ * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
* viewport emulation. Learn more about [viewport emulation](https://playwright.dev/docs/emulation#viewport).
*
* **NOTE** The `null` value opts out from the default presets, makes viewport depend on the host window size defined
@@ -19157,7 +19157,7 @@ export interface BrowserContextOptions {
/**
* Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more
- * about [mobile emulation](https://playwright.dev/docs/emulation#isMobile).
+ * about [mobile emulation](https://playwright.dev/docs/emulation#ismobile).
*/
isMobile?: boolean;
@@ -19421,7 +19421,7 @@ export interface BrowserContextOptions {
videosPath?: string;
/**
- * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
+ * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
* viewport emulation. Learn more about [viewport emulation](https://playwright.dev/docs/emulation#viewport).
*
* **NOTE** The `null` value opts out from the default presets, makes viewport depend on the host window size defined
diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts
index b125181328..b6ba325987 100644
--- a/packages/playwright-test/types/test.d.ts
+++ b/packages/playwright-test/types/test.d.ts
@@ -3575,7 +3575,7 @@ export interface PlaywrightWorkerOptions {
* });
* ```
*
- * Learn more about [automatic screenshots](https://playwright.dev/docs/test-configuration#automatic-screenshots).
+ * Learn more about [automatic screenshots](https://playwright.dev/docs/test-use-options#recording-options).
*/
screenshot: ScreenshotMode | { mode: ScreenshotMode } & Pick<PageScreenshotOptions, 'fullPage' | 'omitBackground'>;
/**
@@ -3601,7 +3601,7 @@ export interface PlaywrightWorkerOptions {
* });
* ```
*
- * Learn more about [recording trace](https://playwright.dev/docs/test-configuration#record-test-trace).
+ * Learn more about [recording trace](https://playwright.dev/docs/test-use-options#recording-options).
*/
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean, screenshots?: boolean, sources?: boolean, attachments?: boolean };
/**
@@ -3629,7 +3629,7 @@ export interface PlaywrightWorkerOptions {
* });
* ```
*
- * Learn more about [recording video](https://playwright.dev/docs/test-configuration#record-video).
+ * Learn more about [recording video](https://playwright.dev/docs/test-use-options#recording-options).
*/
video: VideoMode | /** deprecated */ 'retry-with-video' | { mode: VideoMode, size?: ViewportSize };
}
@@ -3856,7 +3856,7 @@ export interface PlaywrightTestOptions {
*
* Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device,
* so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more
- * about [mobile emulation](https://playwright.dev/docs/emulation#isMobile).
+ * about [mobile emulation](https://playwright.dev/docs/emulation#ismobile).
*/
isMobile: boolean;
/**
@@ -4024,7 +4024,7 @@ export interface PlaywrightTestOptions {
* });
* ```
*
- * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
+ * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use `null` to disable the consistent
* viewport emulation. Learn more about [viewport emulation](https://playwright.dev/docs/emulation#viewport).
*
* **NOTE** The `null` value opts out from the default presets, makes viewport depend on the host window size defined
diff --git a/utils/doclint/cli.js b/utils/doclint/cli.js
index fc6d9d58f2..7e09f90626 100755
--- a/utils/doclint/cli.js
+++ b/utils/doclint/cli.js
@@ -24,6 +24,7 @@ const { parseApi } = require('./api_parser');
const missingDocs = require('./missingDocs');
const md = require('../markdown');
const docs = require('./documentation');
+const toKebabCase = require('lodash/kebabCase')
/** @typedef {import('./documentation').Type} Type */
/** @typedef {import('../markdown').MarkdownNode} MarkdownNode */
@@ -147,24 +148,26 @@ async function run() {
documentation.setCodeGroupsTransformer(lang, tabs => tabs.map(tab => tab.spec));
documentation.generateSourceCodeComments();
- const relevantMarkdownFiles = new Set([...getAllMarkdownFiles(documentationRoot)
- // filter out language specific files
- .filter(filePath => {
- const matches = filePath.match(/(-(js|python|csharp|java))+?/g);
- // no language specific document
- if (!matches)
- return true;
- // there is a language, lets filter for it
- return matches.includes(`-${lang}`);
- })
- // Standardise naming and remove the filter in the file name
- .map(filePath => filePath.replace(/(-(js|python|csharp|java))+/, ''))
- // Internally (playwright.dev generator) we merge test-api and test-reporter-api into api.
- .map(filePath => filePath.replace(/(\/|\\)(test-api|test-reporter-api)(\/|\\)/, `${path.sep}api${path.sep}`))]);
+ const mdLinks = [];
+ const mdSections = new Set();
+
+ for (const cls of documentation.classesArray) {
+ const filePath = path.join(documentationRoot, 'api', 'class-' + cls.name.toLowerCase() + '.md');
+ for (const member of cls.membersArray)
+ mdSections.add(filePath + '#' + toKebabCase(cls.name).toLowerCase() + '-' + toKebabCase(member.name).toLowerCase());
+ for (const event of cls.eventsArray)
+ mdSections.add(filePath + '#' + toKebabCase(cls.name).toLowerCase() + '-event-' + toKebabCase(event.name).toLowerCase());
+ }
for (const filePath of getAllMarkdownFiles(documentationRoot)) {
- if (langs.some(other => other !== lang && filePath.endsWith(`-${other}.md`)))
+ if (!filePath.includes(`-${lang}`) && langs.some(other => other !== lang && filePath.includes(`-${other}`)))
continue;
+
+ // Standardise naming and remove the filter in the file name
+ // Also, Internally (playwright.dev generator) we merge test-api and test-reporter-api into api.
+ const canonicalName = filePath.replace(/(-(js|python|csharp|java))+/, '').replace(/(\/|\\)(test-api|test-reporter-api)(\/|\\)/, `${path.sep}api${path.sep}`);
+ mdSections.add(canonicalName);
+
const data = fs.readFileSync(filePath, 'utf-8');
let rootNode = md.filterNodesForLanguage(md.parse(data), lang);
// Validates code snippet groups.
@@ -174,33 +177,35 @@ async function run() {
// Validate links.
{
md.visitAll(rootNode, node => {
- {
- if (node.type === 'code') {
- const allowedCodeLangs = new Set([
- 'csharp',
- 'java',
- 'js',
- 'ts',
- 'python',
- 'py',
- 'java',
- 'powershell',
- 'batch',
- 'ini',
- 'txt',
- 'html',
- 'xml',
- 'yml',
- 'yaml',
- 'json',
- 'groovy',
- 'html',
- 'bash',
- 'sh',
- ]);
- if (!allowedCodeLangs.has(node.codeLang.split(' ')[0]))
- throw new Error(`${path.relative(PROJECT_DIR, filePath)} contains code block with invalid code block language ${node.codeLang}`);
- }
+ if (node.type === 'code') {
+ const allowedCodeLangs = new Set([
+ 'csharp',
+ 'java',
+ 'js',
+ 'ts',
+ 'python',
+ 'py',
+ 'java',
+ 'powershell',
+ 'batch',
+ 'ini',
+ 'txt',
+ 'html',
+ 'xml',
+ 'yml',
+ 'yaml',
+ 'json',
+ 'groovy',
+ 'html',
+ 'bash',
+ 'sh',
+ ]);
+ if (!allowedCodeLangs.has(node.codeLang.split(' ')[0]))
+ throw new Error(`${path.relative(PROJECT_DIR, filePath)} contains code block with invalid code block language ${node.codeLang}`);
+ }
+ if (node.type.startsWith('h')) {
+ const hash = mdSectionHash(node.text || '');
+ mdSections.add(canonicalName + '#' + hash);
}
if (!node.text)
return;
@@ -208,21 +213,29 @@ async function run() {
const isExternal = mdLink.startsWith('http://') || mdLink.startsWith('https://');
if (isExternal)
continue;
- // ignore links with only a hash (same file)
- if (mdLink.startsWith('#'))
- continue;
-
- let markdownBasePath = path.dirname(filePath);
- let linkWithoutHash = path.join(markdownBasePath, mdLink.split('#')[0]);
- if (path.extname(linkWithoutHash) !== '.md')
- linkWithoutHash += '.md';
- if (!relevantMarkdownFiles.has(linkWithoutHash))
- throw new Error(`${path.relative(PROJECT_DIR, filePath)} references to '${linkWithoutHash}' as '${mdLinkName}' which does not exist.`);
+ const [beforeHash, hash] = mdLink.split('#');
+ let linkWithoutHash = canonicalName;
+ if (beforeHash) {
+ // Not same-file link.
+ linkWithoutHash = path.join(path.dirname(filePath), beforeHash);
+ if (path.extname(linkWithoutHash) !== '.md')
+ linkWithoutHash += '.md';
+ }
+ mdLinks.push({ filePath, linkTarget: linkWithoutHash + (hash ? '#' + hash : ''), name: mdLinkName });
}
});
}
}
+
+ const badLinks = [];
+ for (const { filePath, linkTarget, name } of mdLinks) {
+ if (!mdSections.has(linkTarget))
+ badLinks.push(`${path.relative(PROJECT_DIR, filePath)} references to '${linkTarget}' as '${name}' which does not exist.`);
+ }
+ if (badLinks.length)
+ throw new Error('Broken links found:\n' + badLinks.join('\n'));
+
} catch (e) {
e.message = `While processing "${lang}"\n` + e.message;
throw e;
@@ -280,3 +293,7 @@ async function getBrowserVersions() {
await Promise.all(browsers.map(browser => browser.close()));
return result;
}
+
+function mdSectionHash(text) {
+ return text.toLowerCase().replace(/\s/g, '-').replace(/[^-_a-z0-9]/g, '').replace(/^-+/, '');
+}