docs: update docs (#3253)

- Make docs/README.md more prominent, include capabilities
- Link to examples from specific topics
This commit is contained in:
Dmitry Gozman 2020-07-31 11:58:12 -07:00 committed by GitHub
parent 3edfb2a9d8
commit 928a1769ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 22 deletions

View File

@ -2,7 +2,7 @@
[![npm version](https://img.shields.io/npm/v/playwright.svg?style=flat)](https://www.npmjs.com/package/playwright) [![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://join.slack.com/t/playwright/shared_invite/enQtOTEyMTUxMzgxMjIwLThjMDUxZmIyNTRiMTJjNjIyMzdmZDA3MTQxZWUwZTFjZjQwNGYxZGM5MzRmNzZlMWI5ZWUyOTkzMjE5Njg1NDg) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-86.0.4217.0-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-78.0b5-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> [![WebKit version](https://img.shields.io/badge/webkit-14.0-blue.svg?logo=safari)](https://webkit.org/)
##### [Docs](https://playwright.dev/#?path=docs/README.md) | [API reference](https://playwright.dev/#?path=docs/api.md) | [Changelog](https://github.com/microsoft/playwright/releases)
## [Documentation](https://playwright.dev/#?path=docs/README.md) | [API reference](https://playwright.dev/#?path=docs/api.md)
Playwright is a Node.js 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**.
@ -136,6 +136,6 @@ const { webkit } = require('playwright');
* [Documentation](https://playwright.dev/#?path=docs/README.md)
* [API reference](https://playwright.dev/#?path=docs/api.md)
* [Example recipes](https://playwright.dev/#?path=docs/examples/README.md)
* [Contributing](CONTRIBUTING.md)
* [Community showcase](https://playwright.dev/#?path=docs/showcase.md)
* [Contribution guide](CONTRIBUTING.md)
* [Changelog](https://github.com/microsoft/playwright/releases)

View File

@ -1,5 +1,20 @@
# 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. [Getting Started](./intro.md)
@ -82,4 +97,4 @@
1. [Actionability](./actionability.md)
1. [Extensibility](./extensibility.md)
- [Custom selector engines](./extensibility.md#custom-selector-engines)
1. [API Reference](./api.md)
1. [API Reference](./api.md)

View File

@ -70,6 +70,10 @@ const context = await browser.newContext({
});
```
#### Example
[This script](examples/authentication.js) logs in on GitHub.com through Chromium, and then reuses the login cookies state in WebKit. This recipe can be used to speed up tests by logging in once and reusing login state.
#### API reference
- [class `BrowserContext`](./api.md#class-browsercontext)

View File

@ -1,18 +0,0 @@
# Example recipes
### [Authentication](authentication.js)
This script logs in on GitHub.com through Chromium, and then reuses the login cookies state in WebKit. This recipe can be used to speed up tests by logging in once and reusing login state.
### [File uploads](upload.js)
This script uploads a file to an `input` element that accepts file uploads.
<!--
Other examples
* Request interception/server response stub/mock
* Geolocation and mobile emulation
* Handling a popup, eg, accept dialog
* Page navigation and wait for load
* Async page load (see #662)
-->

View File

@ -251,6 +251,10 @@ await page.setInputFiles('input#upload', {
You can select input files for upload using the `page.setInputFiles` method. It expects first argument to point to an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) with the type `"file"`. Multiple files can be passed in the array. If some of the file paths are relative, they are resolved relative to the [current working directory](https://nodejs.org/api/process.html#process_process_cwd). Empty array clears the selected files.
#### Example
[This script](examples/upload.js) uploads a file to an `input` element that accepts file uploads.
#### API reference
- [page.setInputFiles(selector, files[, options])](https://github.com/microsoft/playwright/blob/master/docs/api.md#pagesetinputfilesselector-value-options)