diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 242a970ab8..b914cdff78 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,6 +1,5 @@
# Contributing
-
- [How to Contribute](#how-to-contribute)
* [Getting Code](#getting-code)
* [Code reviews](#code-reviews)
@@ -13,7 +12,6 @@
* [Public API Coverage](#public-api-coverage)
- [Contributor License Agreement](#contributor-license-agreement)
* [Code of Conduct](#code-of-conduct)
-
## How to Contribute
diff --git a/docs-src/README.md b/docs-src/README.md
new file mode 100644
index 0000000000..e6273e14bd
--- /dev/null
+++ b/docs-src/README.md
@@ -0,0 +1,53 @@
+---
+id: README
+title: "Documentation"
+---
+
+### Capabilities
+
+Playwright is a library to automate [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable** and **fast**.
+
+* Ever-green browser engines
+* Headless execution
+* Scenarios that span multiple pages, domains and iframes
+* Auto-wait for elements to be ready before executing actions (like click, fill)
+* Reliable signals instead of timeouts (like network response, popup, navigation)
+* Intercept network activity for stubbing and mocking network requests
+* Emulate mobile devices, geolocation, permissions
+* Support for web components via shadow-piercing selectors
+* Native input events for mouse and keyboard
+* Upload and download files
+
+### Table of contents
+
+1. Introduction
+ - [Why Playwright?](./why-playwright.md)
+ - [Get started](./intro.md)
+ - [Core concepts](./core-concepts.md)
+ - [Debugging](./debug.md)
+ - [Supported languages](./languages.md)
+1. Guides
+ - [Selectors](./selectors.md)
+ - [Input](./input.md)
+ - [Emulation](./emulation.md)
+ - [Network](./network.md)
+ - [Assertions](./assertions.md)
+ - [Verification](./verification.md)
+ - [Navigations](./navigations.md)
+ - [Multi-page scenarios](./multi-pages.md)
+1. Tutorials
+ - [Authentication](./auth.md)
+ - [Page object models](./pom.md)
+1. Integrations
+ - [Test runners](./test-runners.md)
+ - [Docker](./docker/README.md)
+ - [Continuous integration](./ci.md)
+1. Reference
+ - [API Reference](./api.md)
+ - [Actionability](./actionability.md)
+ - [Advanced installation](./installation.md)
+ - [Extensibility](./extensibility.md)
+1. Get help
+ - [Slack community](https://join.slack.com/t/playwright/shared_invite/enQtOTEyMTUxMzgxMjIwLThjMDUxZmIyNTRiMTJjNjIyMzdmZDA3MTQxZWUwZTFjZjQwNGYxZGM5MzRmNzZlMWI5ZWUyOTkzMjE5Njg1NDg)
+ - [Stack Overflow](https://stackoverflow.com/tags/playwright)
+ - [GitHub](https://github.com/microsoft/playwright/issues)
diff --git a/docs-src/actionability.md b/docs-src/actionability.md
index 6e7e133019..d20b7f6c34 100644
--- a/docs-src/actionability.md
+++ b/docs-src/actionability.md
@@ -1,4 +1,7 @@
-# Actionability
+---
+id: actionability
+title: "Actionability"
+---
Playwright does a range of actionability checks on the elements before performing certain actions. These checks ensure that action behaves as expected, for example Playwright does not click on a disabled button.
diff --git a/docs-src/api-body.md b/docs-src/api-body.md
index 0087e2b98a..e7f039aef4 100644
--- a/docs-src/api-body.md
+++ b/docs-src/api-body.md
@@ -71,7 +71,7 @@ This object can be used to launch or connect to Firefox, returning instances of
## property: Playwright.selectors
- type: <[Selectors]>
-Selectors can be used to install custom selector engines. See [Working with selectors](#working-with-selectors) for more information.
+Selectors can be used to install custom selector engines. See [Working with selectors](./selectors.md#working-with-selectors) for more information.
## property: Playwright.webkit
- type: <[BrowserType]>
@@ -2476,7 +2476,7 @@ console.log(text);
Returns the ElementHandle pointing to the frame element.
The method finds an element matching the specified selector within the frame. See [Working with
-selectors](#working-with-selectors) for more details. If no elements match the selector, returns `null`.
+selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector, returns `null`.
### param: Frame.$.selector = %%-query-selector-%%
@@ -2486,7 +2486,7 @@ selectors](#working-with-selectors) for more details. If no elements match the s
Returns the ElementHandles pointing to the frame elements.
The method finds all elements matching the specified selector within the frame. See [Working with
-selectors](#working-with-selectors) for more details. If no elements match the selector, returns empty array.
+selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector, returns empty array.
### param: Frame.$$.selector = %%-query-selector-%%
@@ -2496,7 +2496,7 @@ selectors](#working-with-selectors) for more details. If no elements match the s
Returns the return value of [`param: pageFunction`]
The method finds an element matching the specified selector within the frame and passes it as a first argument to
-[`param: pageFunction`]. See [Working with selectors](#working-with-selectors) for more details. If no elements match
+[`param: pageFunction`]. See [Working with selectors](./selectors.md#working-with-selectors) for more details. If no elements match
the selector, the method throws an error.
If [`param: pageFunction`] returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return
@@ -2528,7 +2528,7 @@ Optional argument to pass to [`param: pageFunction`]
Returns the return value of [`param: pageFunction`]
The method finds all elements matching the specified selector within the frame and passes an array of matched elements
-as a first argument to [`param: pageFunction`]. See [Working with selectors](#working-with-selectors) for more
+as a first argument to [`param: pageFunction`]. See [Working with selectors](./selectors.md#working-with-selectors) for more
details.
If [`param: pageFunction`] returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return
@@ -3326,7 +3326,7 @@ ElementHandle instances can be used as an argument in [`method: Page.$eval`] and
- returns: <[null]|[ElementHandle]>
The method finds an element matching the specified selector in the `ElementHandle`'s subtree. See [Working with
-selectors](#working-with-selectors) for more details. If no elements match the selector, returns `null`.
+selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector, returns `null`.
### param: ElementHandle.$.selector = %%-query-selector-%%
@@ -3334,7 +3334,7 @@ selectors](#working-with-selectors) for more details. If no elements match the s
- returns: <[Array]<[ElementHandle]>>
The method finds all elements matching the specified selector in the `ElementHandle`s subtree. See [Working with
-selectors](#working-with-selectors) for more details. If no elements match the selector, returns empty array.
+selectors](./selectors.md#working-with-selectors) for more details. If no elements match the selector, returns empty array.
### param: ElementHandle.$$.selector = %%-query-selector-%%
@@ -3344,7 +3344,7 @@ selectors](#working-with-selectors) for more details. If no elements match the s
Returns the return value of [`param: pageFunction`]
The method finds an element matching the specified selector in the `ElementHandle`s subtree and passes it as a first
-argument to [`param: pageFunction`]. See [Working with selectors](#working-with-selectors) for more details. If no
+argument to [`param: pageFunction`]. See [Working with selectors](./selectors.md#working-with-selectors) for more details. If no
elements match the selector, the method throws an error.
If [`param: pageFunction`] returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return
@@ -3376,7 +3376,7 @@ Optional argument to pass to [`param: pageFunction`]
Returns the return value of [`param: pageFunction`]
The method finds all elements matching the specified selector in the `ElementHandle`'s subtree and passes an array of
-matched elements as a first argument to [`param: pageFunction`]. See [Working with selectors](#working-with-selectors)
+matched elements as a first argument to [`param: pageFunction`]. See [Working with selectors](./selectors.md#working-with-selectors)
for more details.
If [`param: pageFunction`] returns a [Promise], then `frame.$$eval` would wait for the promise to resolve and return
@@ -4650,7 +4650,7 @@ Contains the URL of the response.
# class: Selectors
-Selectors can be used to install custom selector engines. See [Working with selectors](#working-with-selectors) for more
+Selectors can be used to install custom selector engines. See [Working with selectors](./selectors.md#working-with-selectors) for more
information.
## async method: Selectors.register
diff --git a/docs-src/api-footer.md b/docs-src/api-footer.md
deleted file mode 100644
index 111d0d4207..0000000000
--- a/docs-src/api-footer.md
+++ /dev/null
@@ -1,157 +0,0 @@
-### EvaluationArgument
-
-Playwright evaluation methods like [`method: Page.evaluate`] take a single optional argument. This argument can be a mix of [Serializable] values and [JSHandle] or [ElementHandle] instances. Handles are automatically converted to the value they represent.
-
-See examples for various scenarios:
-
-```js
-// A primitive value.
-await page.evaluate(num => num, 42);
-
-// An array.
-await page.evaluate(array => array.length, [1, 2, 3]);
-
-// An object.
-await page.evaluate(object => object.foo, { foo: 'bar' });
-
-// A single handle.
-const button = await page.$('button');
-await page.evaluate(button => button.textContent, button);
-
-// Alternative notation using elementHandle.evaluate.
-await button.evaluate((button, from) => button.textContent.substring(from), 5);
-
-// Object with multiple handles.
-const button1 = await page.$('.button1');
-const button2 = await page.$('.button2');
-await page.evaluate(
- o => o.button1.textContent + o.button2.textContent,
- { button1, button2 });
-
-// Obejct destructuring works. Note that property names must match
-// between the destructured object and the argument.
-// Also note the required parenthesis.
-await page.evaluate(
- ({ button1, button2 }) => button1.textContent + button2.textContent,
- { button1, button2 });
-
-// Array works as well. Arbitrary names can be used for destructuring.
-// Note the required parenthesis.
-await page.evaluate(
- ([b1, b2]) => b1.textContent + b2.textContent,
- [button1, button2]);
-
-// Any non-cyclic mix of serializables and handles works.
-await page.evaluate(
- x => x.button1.textContent + x.list[0].textContent + String(x.foo),
- { button1, list: [button2], foo: null });
-```
-
-### Environment Variables
-
-> **NOTE** [playwright-core](https://www.npmjs.com/package/playwright-core) **does not** respect environment variables.
-
-Playwright looks for certain [environment variables](https://en.wikipedia.org/wiki/Environment_variable) to aid its operations.
-If Playwright doesn't find them in the environment, a lowercased variant of these variables will be used from the [npm config](https://docs.npmjs.com/cli/config).
-
-- `PLAYWRIGHT_DOWNLOAD_HOST` - overwrite URL prefix that is used to download browsers. Note: this includes protocol and might even include path prefix. By default, Playwright uses `https://storage.googleapis.com` to download Chromium and `https://playwright.azureedge.net` to download Webkit & Firefox. You can also use browser-specific download hosts that superceed the `PLAYWRIGHT_DOWNLOAD_HOST` variable:
- - `PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST` - host to specify Chromium downloads
- - `PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST` - host to specify Firefox downloads
- - `PLAYWRIGHT_WEBKIT_DOWNLOAD_HOST` - host to specify Webkit downloads
-- `PLAYWRIGHT_BROWSERS_PATH` - specify a shared directory that playwright will use to download browsers and to look for browsers when launching browser instances.
-- `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` - set to non-empty value to skip browser downloads altogether.
-
-```sh
-# Linux/macOS
-# Install browsers to the shared location.
-$ PLAYWRIGHT_BROWSERS_PATH=$HOME/playwright-browsers npm install --save-dev playwright
-# Use shared location to find browsers.
-$ PLAYWRIGHT_BROWSERS_PATH=$HOME/playwright-browsers node playwright-script.js
-
-# Windows
-# Install browsers to the shared location.
-$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\playwright-browsers
-$ npm install --save-dev playwright
-# Use shared location to find browsers.
-$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\playwright-browsers
-$ node playwright-script.js
-```
-
-
-### Working with selectors
-
-Selector describes an element in the page. It can be used to obtain `ElementHandle` (see [`method: Page.$`] for example) or shortcut element operations to avoid intermediate handle (see [`method: Page.click`] for example).
-
-Selector has the following format: `engine=body [>> engine=body]*`. Here `engine` is one of the supported [selector engines](./selectors.md) (e.g. `css` or `xpath`), and `body` is a selector body in the format of the particular engine. When multiple `engine=body` clauses are present (separated by `>>`), next one is queried relative to the previous one's result.
-
-Playwright also supports the following CSS extensions:
-* `:text("string")` - Matches elements that contain specific text node. Learn more about [text selector](./selectors.md#css-extension-text).
-* `:visible` - Matches only visible elements. Learn more about [visible selector](./selectors.md#css-extension-visible).
-* `:light(selector)` - Matches in the light DOM only as opposite to piercing open shadow roots. Learn more about [shadow piercing](./selectors.md#shadow-piercing).
-
-
-For convenience, selectors in the wrong format are heuristically converted to the right format:
-- selector starting with `//` or `..` is assumed to be `xpath=selector`;
-- selector starting and ending with a quote (either `"` or `'`) is assumed to be `text=selector`;
-- otherwise selector is assumed to be `css=selector`.
-
-```js
-// queries 'div' css selector
-const handle = await page.$('css=div');
-
-// queries '//html/body/div' xpath selector
-const handle = await page.$('xpath=//html/body/div');
-
-// queries '"foo"' text selector
-const handle = await page.$('text="foo"');
-
-// queries 'span' css selector inside the result of '//html/body/div' xpath selector
-const handle = await page.$('xpath=//html/body/div >> css=span');
-
-// converted to 'css=div'
-const handle = await page.$('div');
-
-// converted to 'xpath=//html/body/div'
-const handle = await page.$('//html/body/div');
-
-// converted to 'text="foo"'
-const handle = await page.$('"foo"');
-
-// queries '../span' xpath selector starting with the result of 'div' css selector
-const handle = await page.$('div >> ../span');
-
-// queries 'span' css selector inside the div handle
-const handle = await divHandle.$('css=span');
-```
-
-### Working with Chrome Extensions
-
-Playwright can be used for testing Chrome Extensions.
-
-> **NOTE** Extensions in Chrome / Chromium currently only work in non-headless mode.
-
-The following is code for getting a handle to the [background page](https://developer.chrome.com/extensions/background_pages) of an extension whose source is located in `./my-extension`:
-```js
-const { chromium } = require('playwright');
-
-(async () => {
- const pathToExtension = require('path').join(__dirname, 'my-extension');
- const userDataDir = '/tmp/test-user-data-dir';
- const browserContext = await chromium.launchPersistentContext(userDataDir,{
- headless: false,
- args: [
- `--disable-extensions-except=${pathToExtension}`,
- `--load-extension=${pathToExtension}`
- ]
- });
- const backgroundPage = browserContext.backgroundPages()[0];
- // Test the background page as you would any other page.
- await browserContext.close();
-})();
-```
-
-> **NOTE** It is not yet possible to test extension popups or content scripts.
-
-
diff --git a/docs-src/api-header.md b/docs-src/api-header.md
deleted file mode 100644
index bb1fe1acbc..0000000000
--- a/docs-src/api-header.md
+++ /dev/null
@@ -1,7 +0,0 @@
-
-# Playwright API Tip-Of-Tree
-
-##### Table of Contents
-
-
-
diff --git a/docs-src/api-params.md b/docs-src/api-params.md
index f198d8884c..c88a192b8c 100644
--- a/docs-src/api-params.md
+++ b/docs-src/api-params.md
@@ -45,7 +45,7 @@ Whether to bypass the [actionability](./actionability.md) checks. Defaults to `f
- `selector` <[string]>
A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See
-[working with selectors](#working-with-selectors) for more details.
+[working with selectors](./selectors.md#working-with-selectors) for more details.
## input-position
- `position` <[Object]>
@@ -85,7 +85,7 @@ defaults to 1. See [UIEvent.detail].
## query-selector
- `selector` <[string]>
-A selector to query for. See [working with selectors](#working-with-selectors) for more details.
+A selector to query for. See [working with selectors](./selectors.md#working-with-selectors) for more details.
## wait-for-selector-state
- `state` <"attached"|"detached"|"visible"|"hidden">
diff --git a/docs-src/assertions.md b/docs-src/assertions.md
index 7c0bf3b4c5..79a36b0a32 100644
--- a/docs-src/assertions.md
+++ b/docs-src/assertions.md
@@ -1,14 +1,14 @@
-# Assertions
+---
+id: assertions
+title: "Assertions"
+---
The Playwright API can be used to read element contents and properties for test assertions. These values are fetched from the browser page and asserted in
Node.js.
The examples in this guide use the built-in [`assert` module](https://nodejs.org/api/assert.html), but they can be used with any assertion library (like [Expect](https://www.npmjs.com/package/expect) or [Chai](https://www.npmjs.com/package/chai)). See [Test runners](test-runners.md) for more info.
-
-
-
-
+
## Common patterns
diff --git a/docs-src/auth.md b/docs-src/auth.md
index 5e1100398a..c77c0221c7 100644
--- a/docs-src/auth.md
+++ b/docs-src/auth.md
@@ -1,4 +1,8 @@
-# Authentication
+---
+id: auth
+title: "Authentication"
+---
+
Playwright can be used to automate scenarios that require authentication.
Tests written with Playwright execute in isolated clean-slate environments called
@@ -11,8 +15,7 @@ login in every context and speeds up test execution.
app UI). For [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication)
use [`browser.newContext`](./network.md#http-authentication).
-
-
+
## Automate logging in
diff --git a/docs-src/ci.md b/docs-src/ci.md
index b9a0f681cc..436fdf24dc 100644
--- a/docs-src/ci.md
+++ b/docs-src/ci.md
@@ -1,10 +1,12 @@
-# Continuous Integration
+---
+id: ci
+title: "Continuous Integration"
+---
Playwright tests can be executed in CI environments. We have created sample
configurations for common CI providers.
-
-
+
## Introduction
diff --git a/docs-src/cli.md b/docs-src/cli.md
index 33e64be1ad..bc02374335 100644
--- a/docs-src/cli.md
+++ b/docs-src/cli.md
@@ -1,9 +1,11 @@
-# Playwright CLI
+---
+id: cli
+title: "Command Line Interface"
+---
Playwright comes with the command line tools that run via `npx` or as a part of the `npm` scripts.
-
-
+
## Usage
diff --git a/docs-src/core-concepts.md b/docs-src/core-concepts.md
index fe95bf2d4e..c98735972a 100644
--- a/docs-src/core-concepts.md
+++ b/docs-src/core-concepts.md
@@ -1,4 +1,7 @@
-# Core concepts
+---
+id: core-concepts
+title: "Core concepts"
+---
Playwright provides a set of APIs to automate Chromium, Firefox and WebKit
browsers. By using the Playwright API, you can write JavaScript code to create
@@ -8,8 +11,7 @@ Along with a test runner Playwright can be used to automate user interactions to
validate and test web applications. The Playwright API enables this through
the following primitives.
-
-
+
@@ -245,10 +247,53 @@ const status = await page.evaluate(async () => {
});
```
-### Evaluation
+## Evaluation Argument
+
+Playwright evaluation methods like [`method: Page.evaluate`] take a single optional argument. This argument can be a mix of [Serializable] values and [JSHandle] or [ElementHandle] instances. Handles are automatically converted to the value they represent.
+
+```js
+// A primitive value.
+await page.evaluate(num => num, 42);
+
+// An array.
+await page.evaluate(array => array.length, [1, 2, 3]);
+
+// An object.
+await page.evaluate(object => object.foo, { foo: 'bar' });
+
+// A single handle.
+const button = await page.$('button');
+await page.evaluate(button => button.textContent, button);
+
+// Alternative notation using elementHandle.evaluate.
+await button.evaluate((button, from) => button.textContent.substring(from), 5);
+
+// Object with multiple handles.
+const button1 = await page.$('.button1');
+const button2 = await page.$('.button2');
+await page.evaluate(
+ o => o.button1.textContent + o.button2.textContent,
+ { button1, button2 });
+
+// Object destructuring works. Note that property names must match
+// between the destructured object and the argument.
+// Also note the required parenthesis.
+await page.evaluate(
+ ({ button1, button2 }) => button1.textContent + button2.textContent,
+ { button1, button2 });
+
+// Array works as well. Arbitrary names can be used for destructuring.
+// Note the required parenthesis.
+await page.evaluate(
+ ([b1, b2]) => b1.textContent + b2.textContent,
+ [button1, button2]);
+
+// Any non-cyclic mix of serializables and handles works.
+await page.evaluate(
+ x => x.button1.textContent + x.list[0].textContent + String(x.foo),
+ { button1, list: [button2], foo: null });
+```
-Functions passed inside [`method: Page.evaluate`] can accept parameters. These parameters are
-serialized and sent into your web page over the wire. You can pass primitive types, JSON-alike objects and remote object handles received from the page.
Right:
diff --git a/docs-src/debug.md b/docs-src/debug.md
index 098947ed91..9e900e6aa8 100644
--- a/docs-src/debug.md
+++ b/docs-src/debug.md
@@ -1,11 +1,13 @@
-# Debugging tools
+---
+id: debug
+title: "Debugging tools"
+---
Playwright scripts work with existing debugging tools, like Node.js debuggers
and browser developer tools. Playwright also introduces new debugging features
for browser automation.
-
-
+
## Run in headful mode
diff --git a/docs-src/emulation.md b/docs-src/emulation.md
index cf9403f796..5f2bf49a24 100644
--- a/docs-src/emulation.md
+++ b/docs-src/emulation.md
@@ -1,4 +1,7 @@
-# Device and environment emulation
+---
+id: emulation
+title: "Device and environment emulation"
+---
Playwright allows overriding various parameters of the device where the browser is running:
- viewport size, device scale factor, touch support
@@ -8,8 +11,7 @@ Playwright allows overriding various parameters of the device where the browser
Most of these parameters are configured during the browser context construction, but some of them such as viewport size can be changed for individual pages.
-
-
+
diff --git a/docs-src/extensibility.md b/docs-src/extensibility.md
index b439fcd687..5372921381 100644
--- a/docs-src/extensibility.md
+++ b/docs-src/extensibility.md
@@ -1,7 +1,9 @@
-# Extensibility
+---
+id: extensibility
+title: "Extensibility"
+---
-
-
+
## Custom selector engines
diff --git a/docs-src/input.md b/docs-src/input.md
index e2b4f51ac8..fcfd6278ac 100644
--- a/docs-src/input.md
+++ b/docs-src/input.md
@@ -1,9 +1,9 @@
-# Input
+---
+id: input
+title: "Input"
+---
-
-
-
-
+
## Text input
diff --git a/docs-src/installation.md b/docs-src/installation.md
index 7aaa2320c3..1d647eb24a 100644
--- a/docs-src/installation.md
+++ b/docs-src/installation.md
@@ -1,9 +1,9 @@
-# Advanced installation
+---
+id: installation
+title: "Advanced installation"
+---
-
-
-
-
+
## Managing browser binaries
diff --git a/docs-src/intro.md b/docs-src/intro.md
index 941b0b0dfc..7310bafeff 100644
--- a/docs-src/intro.md
+++ b/docs-src/intro.md
@@ -1,7 +1,9 @@
-# Getting Started
+---
+id: intro
+title: "Getting Started"
+---
-
-
+
## Installation
diff --git a/docs-src/languages.md b/docs-src/languages.md
index 70942b8f21..a187c4224f 100644
--- a/docs-src/languages.md
+++ b/docs-src/languages.md
@@ -1,9 +1,11 @@
-# Supported languages
+---
+id: languages
+title: "Supported languages"
+---
The Playwright API is available in multiple languages.
-
-
+
## JavaScript and TypeScript
diff --git a/docs-src/api-links.md b/docs-src/links.md
similarity index 96%
rename from docs-src/api-links.md
rename to docs-src/links.md
index 3a3cd3cf4b..74f2e36253 100644
--- a/docs-src/api-links.md
+++ b/docs-src/links.md
@@ -3,7 +3,7 @@
[ChildProcess]: https://nodejs.org/api/child_process.html "ChildProcess"
[Element]: https://developer.mozilla.org/en-US/docs/Web/API/element "Element"
[Error]: https://nodejs.org/api/errors.html#errors_class_error "Error"
-[EvaluationArgument]: #evaluationargument "Evaluation Argument"
+[Evaluation Argument]: ./core-concepts.md#evaluationargument "Evaluation Argument"
[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map"
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object"
[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise"
diff --git a/docs-src/mobile.md b/docs-src/mobile.md
index a14eb1a0d5..9ece9a1615 100644
--- a/docs-src/mobile.md
+++ b/docs-src/mobile.md
@@ -1,4 +1,9 @@
-# Experimental support for Chrome for Android
+---
+id: mobile
+title: "Experimental support for Chrome for Android"
+---
+
+
You can try Playwright against Chrome for Android today. This support is experimental. Support for devices is tracked in the issue [#1122](https://github.com/microsoft/playwright/issues/1122).
diff --git a/docs-src/multi-pages.md b/docs-src/multi-pages.md
index 91f9db1ea8..b6375e7bb0 100644
--- a/docs-src/multi-pages.md
+++ b/docs-src/multi-pages.md
@@ -1,10 +1,12 @@
-# Multi-page scenarios
+---
+id: multi-pages
+title: "Multi-page scenarios"
+---
Playwright can automate scenarios that span multiple browser contexts or multiple
tabs in a browser window.
-
-
+
## Multiple contexts
diff --git a/docs-src/navigations.md b/docs-src/navigations.md
index 98fd1b63f2..86f40b6b7d 100644
--- a/docs-src/navigations.md
+++ b/docs-src/navigations.md
@@ -1,9 +1,11 @@
-# Navigations
+---
+id: navigations
+title: "Navigations"
+---
Playwright can navigate to URLs and handle navigations caused by page interactions. This guide covers common scenarios to wait for page navigations and loading to complete.
-
-
+
## Navigation lifecycle
Playwright splits the process of showing a new document in a page into **navigation** and **loading**.
diff --git a/docs-src/network.md b/docs-src/network.md
index 73ac24195a..8af4fe6487 100644
--- a/docs-src/network.md
+++ b/docs-src/network.md
@@ -1,11 +1,13 @@
-# Network
+---
+id: network
+title: "Network"
+---
Playwright provides APIs to **monitor** and **modify** network traffic, both HTTP and HTTPS.
Any requests that page does, including [XHRs](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) and
[fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) requests, can be tracked, modified and handled.
-
-
+
diff --git a/docs-src/pom.md b/docs-src/pom.md
index 8d4992e357..ce294f60ac 100644
--- a/docs-src/pom.md
+++ b/docs-src/pom.md
@@ -1,9 +1,12 @@
-# Page Object Models
+---
+id: pom
+title: "Page Object Models"
+---
+
Large test suites can be structured to optimize ease of authoring and maintenance.
Page object models are one such approach to structure your test suite.
-
-
+
## Introduction
A page object represents a part of your web application. An e-commerce web
diff --git a/docs-src/selectors.md b/docs-src/selectors.md
index f0ff5349a4..5715d35042 100644
--- a/docs-src/selectors.md
+++ b/docs-src/selectors.md
@@ -1,9 +1,85 @@
-# Element selectors
+---
+id: selectors
+title: "Element selectors"
+---
Selectors query elements on the web page for interactions, like [`method: Page.click`], and to obtain `ElementHandle` through [`method: Page.$`]. Built-in selectors auto-pierce [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM).
-
-
+
+
+## Working with selectors
+
+Selector describes an element in the page. It can be used to obtain `ElementHandle` (see [`method: Page.$`] for example) or shortcut element operations to avoid intermediate handle (see [`method: Page.click`] for example).
+
+Selector has the following format: `engine=body [>> engine=body]*`. Here `engine` is one of the supported [selector engines](./selectors.md) (e.g. `css` or `xpath`), and `body` is a selector body in the format of the particular engine. When multiple `engine=body` clauses are present (separated by `>>`), next one is queried relative to the previous one's result.
+
+Playwright also supports the following CSS extensions:
+* `:text("string")` - Matches elements that contain specific text node. Learn more about [text selector](./selectors.md#css-extension-text).
+* `:visible` - Matches only visible elements. Learn more about [visible selector](./selectors.md#css-extension-visible).
+* `:light(selector)` - Matches in the light DOM only as opposite to piercing open shadow roots. Learn more about [shadow piercing](./selectors.md#shadow-piercing).
+
+
+For convenience, selectors in the wrong format are heuristically converted to the right format:
+- selector starting with `//` or `..` is assumed to be `xpath=selector`;
+- selector starting and ending with a quote (either `"` or `'`) is assumed to be `text=selector`;
+- otherwise selector is assumed to be `css=selector`.
+
+```js
+// queries 'div' css selector
+const handle = await page.$('css=div');
+
+// queries '//html/body/div' xpath selector
+const handle = await page.$('xpath=//html/body/div');
+
+// queries '"foo"' text selector
+const handle = await page.$('text="foo"');
+
+// queries 'span' css selector inside the result of '//html/body/div' xpath selector
+const handle = await page.$('xpath=//html/body/div >> css=span');
+
+// converted to 'css=div'
+const handle = await page.$('div');
+
+// converted to 'xpath=//html/body/div'
+const handle = await page.$('//html/body/div');
+
+// converted to 'text="foo"'
+const handle = await page.$('"foo"');
+
+// queries '../span' xpath selector starting with the result of 'div' css selector
+const handle = await page.$('div >> ../span');
+
+// queries 'span' css selector inside the div handle
+const handle = await divHandle.$('css=span');
+```
+
+### Working with Chrome Extensions
+
+Playwright can be used for testing Chrome Extensions.
+
+> **NOTE** Extensions in Chrome / Chromium currently only work in non-headless mode.
+
+The following is code for getting a handle to the [background page](https://developer.chrome.com/extensions/background_pages) of an extension whose source is located in `./my-extension`:
+```js
+const { chromium } = require('playwright');
+
+(async () => {
+ const pathToExtension = require('path').join(__dirname, 'my-extension');
+ const userDataDir = '/tmp/test-user-data-dir';
+ const browserContext = await chromium.launchPersistentContext(userDataDir,{
+ headless: false,
+ args: [
+ `--disable-extensions-except=${pathToExtension}`,
+ `--load-extension=${pathToExtension}`
+ ]
+ });
+ const backgroundPage = browserContext.backgroundPages()[0];
+ // Test the background page as you would any other page.
+ await browserContext.close();
+})();
+```
## Syntax
Selectors are defined by selector engine name and selector body, `engine=body`.
diff --git a/docs-src/showcase.md b/docs-src/showcase.md
index fe2c4564fb..bf91c581e4 100644
--- a/docs-src/showcase.md
+++ b/docs-src/showcase.md
@@ -1,4 +1,7 @@
-# Community Showcase
+---
+id: showcase
+title: "Community Showcase"
+---
## Users
diff --git a/docs-src/test-runners.md b/docs-src/test-runners.md
index f1f6d10bc7..a1305e370c 100644
--- a/docs-src/test-runners.md
+++ b/docs-src/test-runners.md
@@ -1,13 +1,11 @@
-# Test Runners
+---
+id: test-runners
+title: "Test Runners"
+---
With a few lines of code, you can hook up Playwright to your favorite JavaScript test runner.
-
-
-
-
-
-
+
## Jest / Jasmine
diff --git a/docs-src/troubleshooting.md b/docs-src/troubleshooting.md
index 40a53ae199..025b948000 100644
--- a/docs-src/troubleshooting.md
+++ b/docs-src/troubleshooting.md
@@ -1,7 +1,9 @@
-# Troubleshooting
+---
+id: troubleshooting
+title: "Troubleshooting"
+---
-
-
+
## Browser dependencies
diff --git a/docs-src/verification.md b/docs-src/verification.md
index 172c59a34a..fbcf4e14f0 100644
--- a/docs-src/verification.md
+++ b/docs-src/verification.md
@@ -1,9 +1,9 @@
-# Verification
+---
+id: verification
+title: "Verification"
+---
-
-
-
-
+
## Videos
diff --git a/docs-src/why-playwright.md b/docs-src/why-playwright.md
index 3a10ae0d4d..26cb7dbbba 100644
--- a/docs-src/why-playwright.md
+++ b/docs-src/why-playwright.md
@@ -1,9 +1,11 @@
-# Why Playwright?
+---
+id: why-playwright
+title: "Why Playwright?"
+---
Playwright enables fast, reliable and capable automation across all modern browsers. This guide covers those key differentiators to help you decide on the right tool for your automated tests.
-
-
+
## Support for all browsers
* **Test on Chromium, Firefox and WebKit**. Playwright has full API coverage for all modern browsers, including Google Chrome and Microsoft Edge (with [Chromium](https://www.chromium.org/)), Apple Safari (with [WebKit](https://webkit.org/)) and Mozilla Firefox.
diff --git a/docs/README.md b/docs/README.md
index 7f3e657812..1599dcdd09 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,9 +1,11 @@
-# Documentation
+---
+id: README
+title: "Documentation"
+---
### Capabilities
Playwright is a library to automate [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable** and **fast**.
-
* Ever-green browser engines
* Headless execution
* Scenarios that span multiple pages, domains and iframes
@@ -16,36 +18,91 @@ Playwright is a library to automate [Chromium](https://www.chromium.org/Home), [
* Upload and download files
### Table of contents
-
1. Introduction
- - [Why Playwright?](./why-playwright.md)
- - [Get started](./intro.md)
- - [Core concepts](./core-concepts.md)
- - [Debugging](./debug.md)
- - [Supported languages](./languages.md)
- - [Using Playwright CLI](./cli.md)
+ - [Why Playwright?](./why-playwright.md)
+ - [Get started](./intro.md)
+ - [Core concepts](./core-concepts.md)
+ - [Debugging](./debug.md)
+ - [Supported languages](./languages.md)
1. Guides
- - [Selectors](./selectors.md)
- - [Input](./input.md)
- - [Emulation](./emulation.md)
- - [Network](./network.md)
- - [Assertions](./assertions.md)
- - [Verification](./verification.md)
- - [Navigations](./navigations.md)
- - [Multi-page scenarios](./multi-pages.md)
+ - [Selectors](./selectors.md)
+ - [Input](./input.md)
+ - [Emulation](./emulation.md)
+ - [Network](./network.md)
+ - [Assertions](./assertions.md)
+ - [Verification](./verification.md)
+ - [Navigations](./navigations.md)
+ - [Multi-page scenarios](./multi-pages.md)
1. Tutorials
- - [Authentication](./auth.md)
- - [Page object models](./pom.md)
+ - [Authentication](./auth.md)
+ - [Page object models](./pom.md)
1. Integrations
- - [Test runners](./test-runners.md)
- - [Docker](./docker/README.md)
- - [Continuous integration](./ci.md)
+ - [Test runners](./test-runners.md)
+ - [Docker](./docker/README.md)
+ - [Continuous integration](./ci.md)
1. Reference
- - [API Reference](./api.md)
- - [Actionability](./actionability.md)
- - [Advanced installation](./installation.md)
- - [Extensibility](./extensibility.md)
+ - [API Reference](./api.md)
+ - [Actionability](./actionability.md)
+ - [Advanced installation](./installation.md)
+ - [Extensibility](./extensibility.md)
1. Get help
- - [Slack community](https://join.slack.com/t/playwright/shared_invite/enQtOTEyMTUxMzgxMjIwLThjMDUxZmIyNTRiMTJjNjIyMzdmZDA3MTQxZWUwZTFjZjQwNGYxZGM5MzRmNzZlMWI5ZWUyOTkzMjE5Njg1NDg)
- - [Stack Overflow](https://stackoverflow.com/tags/playwright)
- - [GitHub](https://github.com/microsoft/playwright/issues)
+ - [Slack community](https://join.slack.com/t/playwright/shared_invite/enQtOTEyMTUxMzgxMjIwLThjMDUxZmIyNTRiMTJjNjIyMzdmZDA3MTQxZWUwZTFjZjQwNGYxZGM5MzRmNzZlMWI5ZWUyOTkzMjE5Njg1NDg)
+ - [Stack Overflow](https://stackoverflow.com/tags/playwright)
+ - [GitHub](https://github.com/microsoft/playwright/issues)
+[Playwright]: api/class-playwright.md "Playwright"
+[Browser]: api/class-browser.md "Browser"
+[BrowserContext]: api/class-browsercontext.md "BrowserContext"
+[Page]: api/class-page.md "Page"
+[Frame]: api/class-frame.md "Frame"
+[ElementHandle]: api/class-elementhandle.md "ElementHandle"
+[JSHandle]: api/class-jshandle.md "JSHandle"
+[ConsoleMessage]: api/class-consolemessage.md "ConsoleMessage"
+[Dialog]: api/class-dialog.md "Dialog"
+[Download]: api/class-download.md "Download"
+[Video]: api/class-video.md "Video"
+[FileChooser]: api/class-filechooser.md "FileChooser"
+[Keyboard]: api/class-keyboard.md "Keyboard"
+[Mouse]: api/class-mouse.md "Mouse"
+[Touchscreen]: api/class-touchscreen.md "Touchscreen"
+[Request]: api/class-request.md "Request"
+[Response]: api/class-response.md "Response"
+[Selectors]: api/class-selectors.md "Selectors"
+[Route]: api/class-route.md "Route"
+[WebSocket]: api/class-websocket.md "WebSocket"
+[TimeoutError]: api/class-timeouterror.md "TimeoutError"
+[Accessibility]: api/class-accessibility.md "Accessibility"
+[Worker]: api/class-worker.md "Worker"
+[BrowserServer]: api/class-browserserver.md "BrowserServer"
+[BrowserType]: api/class-browsertype.md "BrowserType"
+[Logger]: api/class-logger.md "Logger"
+[ChromiumBrowser]: api/class-chromiumbrowser.md "ChromiumBrowser"
+[ChromiumBrowserContext]: api/class-chromiumbrowsercontext.md "ChromiumBrowserContext"
+[ChromiumCoverage]: api/class-chromiumcoverage.md "ChromiumCoverage"
+[CDPSession]: api/class-cdpsession.md "CDPSession"
+[FirefoxBrowser]: api/class-firefoxbrowser.md "FirefoxBrowser"
+[WebKitBrowser]: api/class-webkitbrowser.md "WebKitBrowser"
+[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array"
+[Buffer]: https://nodejs.org/api/buffer.html#buffer_class_buffer "Buffer"
+[ChildProcess]: https://nodejs.org/api/child_process.html "ChildProcess"
+[Element]: https://developer.mozilla.org/en-US/docs/Web/API/element "Element"
+[Error]: https://nodejs.org/api/errors.html#errors_class_error "Error"
+[Evaluation Argument]: ./core-concepts.md#evaluationargument "Evaluation Argument"
+[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map "Map"
+[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object"
+[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise"
+[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp "RegExp"
+[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"
+[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail"
+[URL]: https://nodejs.org/api/url.html "URL"
+[USKeyboardLayout]: ../src/usKeyboardLayout.ts "USKeyboardLayout"
+[UnixTime]: https://en.wikipedia.org/wiki/Unix_time "Unix Time"
+[boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean"
+[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function "Function"
+[iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols "Iterator"
+[null]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null"
+[number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number"
+[origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin "Origin"
+[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector"
+[Readable]: https://nodejs.org/api/stream.html#stream_class_stream_readable "Readable"
+[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string"
+[xpath]: https://developer.mozilla.org/en-US/docs/Web/XPath "xpath"
diff --git a/docs/actionability.md b/docs/actionability.md
index e2eafc01af..a776cf910a 100644
--- a/docs/actionability.md
+++ b/docs/actionability.md
@@ -1,18 +1,13 @@
-
+---
+id: actionability
+title: "Actionability"
+---
-# Actionability
+Playwright does a range of actionability checks on the elements before performing certain actions. These checks ensure that action behaves as expected, for example Playwright does not click on a disabled button.
-Playwright does a range of actionability checks on the elements before
-performing certain actions. These checks ensure that action behaves as expected,
-for example Playwright does not click on a disabled button.
+Playwright waits until all the relevant actionability checks pass before performing an action. This means that action will fail with `TimeoutError` if checks do not pass within the specified `timeout`.
-Playwright waits until all the relevant actionability checks pass before
-performing an action. This means that action will fail with `TimeoutError` if
-checks do not pass within the specified `timeout`.
-
-Some actions like `page.click()` support `{force: true}` option that disable
-non-essential actionability checks, for example passing `force` to `click()`
-method will not check that the target element actually receives click events.
+Some actions like `page.click()` support `{force: true}` option that disable non-essential actionability checks, for example passing `force` to `click()` method will not check that the target element actually receives click events.
| Actions | Performed checks |
| ------ | ------- |
@@ -26,19 +21,15 @@ method will not check that the target element actually receives click events.
### Visible
-Element is considered visible when it has non-empty bounding box and does not
-have `visibility:hidden` computed style. Note that elements of zero size or with
-`display:none` are not considered visible.
+Element is considered visible when it has non-empty bounding box and does not have `visibility:hidden` computed style. Note that elements of zero size or with `display:none` are not considered visible.
### Stable
-Element is considered stable when it has maintained the same bounding box for at
-least two consecutive animation frames.
+Element is considered stable when it has maintained the same bounding box for at least two consecutive animation frames.
### Enabled
-Element is considered enabled when it is not a `