Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs(intro): add cli to getting started (#3821)
Arjun Attam777689a96aa9
diff --git a/docs/README.md b/docs/README.mdindex 9a84c84592..f16427141f 100644--- a/docs/README.md+++ b/docs/README.md@@ -19,8 +19,7 @@ Playwright is a library to automate [Chromium](https://www.chromium.org/Home), [1. Introduction- [Why Playwright?](./why-playwright.md)- - [Getting started](./intro.md)- - [First script](./intro.md#first-script)+ - [Get started](./intro.md)- [Core concepts](./core-concepts.md)- [Debugging](./debug.md)1. Guidesdiff --git a/docs/intro.md b/docs/intro.mdindex d949b0f078..51fbe8c70c 100644--- a/docs/intro.md+++ b/docs/intro.md@@ -1,26 +1,23 @@# Getting Started-<!-- GEN:toc -->+<!-- GEN:toc-top-level -->- [Installation](#installation)- [Usage](#usage)- [First script](#first-script)+- [Record scripts](#record-scripts)+- [TypeScript support](#typescript-support)- [System requirements](#system-requirements)-- [TypeScript IDE support](#typescript-ide-support)<!-- GEN:stop -->-<br>-## Installation-Use npm or Yarn to install Playwright in your Node.js project. Playwright requires Node.js 10 or higher.+Use npm or Yarn to install Playwright in your Node.js project. See [system requirements](#system-requirements).```shnpm i -D playwright```-During installation, Playwright downloads browser binaries for Chromium, Firefox and WebKit. This sets up your environment for browser automation with just one command. It is possible to modify this default behavior for monorepos and other scenarios. See [installation parameters](installation.md) for mode details.--<br>+This single command downloads the Playwright NPM package and browser binaries for Chromium, Firefox and WebKit. To modify this behavior see [installation parameters](installation.md).## Usage@@ -36,7 +33,7 @@ const { chromium } = require('playwright');})();```-Playwright APIs are asynchronous and return Promise objects. Our code examples use [the async/await pattern](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await) to simplify comprehension. The code is wrapped in an unnamed async arrow function which is invoking itself.+Playwright APIs are asynchronous and return Promise objects. Our code examples use [the async/await pattern](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await) to ease readability. The code is wrapped in an unnamed async arrow function which is invoking itself.```js(async () => { // Start of async arrow function@@ -45,8 +42,6 @@ Playwright APIs are asynchronous and return Promise objects. Our code examples u})(); // End of the function and () to invoke itself```-<br>-## First scriptIn our first script, we will navigate to `whatsmyuseragent.org` and take a screenshot in WebKit.@@ -69,43 +64,49 @@ By default, Playwright runs the browsers in headless mode. To see the browser UIfirefox.launch({ headless: false, slowMo: 50 });```-<br>--## System requirements+## Record scripts-Playwright requires Node.js version 10.15 or above. The browser binaries for Chromium,-Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):+[Playwright CLI](https://www.npmjs.com/package/playwright-cli) can be used to record user interactions and generate JavaScript code.-* **Windows**: Works with Windows and Windows Subsystem for Linux (WSL).-* **macOS**: Requires 10.14 or above.-* **Linux**: Depending on your Linux distribution, you might need to install additional- dependencies to run the browsers.- * Firefox requires Ubuntu 18.04+- * For Ubuntu 18.04, the additional dependencies are defined in [our Docker image](docker/Dockerfile.bionic),- which is based on Ubuntu.--<br>--## TypeScript IDE support--Playwright comes with built-in support for TypeScript. Playwright type definitions will be imported automatically.+```+npx playwright-cli codegen wikipedia.org+```-It is also possible to add these types to your variables manually. In TypeScript:+## TypeScript support-```ts-let page: import('playwright').Page;-```+Playwright includes built-in support for TypeScript. Type definitions will be imported automatically. It is recommended to use type-checking to improve the IDE experience.-If you use JavaScript, you can still use TypeScript definitions for improved auto-completions and warnings in Visual Studio Code or WebStorm. Add the following to the top of your JavaScript file:+### In JavaScript+Add the following to the top of your JavaScript file to get type-checking in VS Code or WebStorm.```js//@ts-check// ...```-You can also use JSDoc to set types for variables.+Alternatively, you can use JSDoc to set types for variables.```js/** @type {import('playwright').Page} */let page;```++### In TypeScript+TypeScript support will work out-of-the-box. Types can also be imported explicitly.++```ts+let page: import('playwright').Page;+```++## System requirements++Playwright requires Node.js version 10.17 or above. The browser binaries for Chromium,+Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):++* **Windows**: Works with Windows and Windows Subsystem for Linux (WSL).+* **macOS**: Requires 10.14 or above.+* **Linux**: Depending on your Linux distribution, you might need to install additional+ dependencies to run the browsers.+ * Firefox requires Ubuntu 18.04++ * For Ubuntu 18.04, the additional dependencies are defined in [our Docker image](docker/Dockerfile.bionic),+ which is based on Ubuntu.