Skip to content

Commit 777689a

Browse files
authored
docs(intro): add cli to getting started (#3821)
* docs(intro): add cli to getting started * fix doclint
1 parent 29b8098 commit 777689a

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

docs/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ Playwright is a library to automate [Chromium](https://www.chromium.org/Home), [
1919

2020
1. Introduction
2121
- [Why Playwright?](./why-playwright.md)
22-
- [Getting started](./intro.md)
23-
- [First script](./intro.md#first-script)
22+
- [Get started](./intro.md)
2423
- [Core concepts](./core-concepts.md)
2524
- [Debugging](./debug.md)
2625
1. Guides

docs/intro.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
# Getting Started
22

3-
<!-- GEN:toc -->
3+
<!-- GEN:toc-top-level -->
44
- [Installation](#installation)
55
- [Usage](#usage)
66
- [First script](#first-script)
7+
- [Record scripts](#record-scripts)
8+
- [TypeScript support](#typescript-support)
79
- [System requirements](#system-requirements)
8-
- [TypeScript IDE support](#typescript-ide-support)
910
<!-- GEN:stop -->
1011

11-
<br>
12-
1312
## Installation
1413

15-
Use npm or Yarn to install Playwright in your Node.js project. Playwright requires Node.js 10 or higher.
14+
Use npm or Yarn to install Playwright in your Node.js project. See [system requirements](#system-requirements).
1615

1716
```sh
1817
npm i -D playwright
1918
```
2019

21-
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.
22-
23-
<br>
20+
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).
2421

2522
## Usage
2623

@@ -36,7 +33,7 @@ const { chromium } = require('playwright');
3633
})();
3734
```
3835

39-
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.
36+
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.
4037

4138
```js
4239
(async () => { // Start of async arrow function
@@ -45,8 +42,6 @@ Playwright APIs are asynchronous and return Promise objects. Our code examples u
4542
})(); // End of the function and () to invoke itself
4643
```
4744

48-
<br>
49-
5045
## First script
5146

5247
In 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 UI
6964
firefox.launch({ headless: false, slowMo: 50 });
7065
```
7166

72-
<br>
73-
74-
## System requirements
67+
## Record scripts
7568

76-
Playwright requires Node.js version 10.15 or above. The browser binaries for Chromium,
77-
Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):
69+
[Playwright CLI](https://www.npmjs.com/package/playwright-cli) can be used to record user interactions and generate JavaScript code.
7870

79-
* **Windows**: Works with Windows and Windows Subsystem for Linux (WSL).
80-
* **macOS**: Requires 10.14 or above.
81-
* **Linux**: Depending on your Linux distribution, you might need to install additional
82-
dependencies to run the browsers.
83-
* Firefox requires Ubuntu 18.04+
84-
* For Ubuntu 18.04, the additional dependencies are defined in [our Docker image](docker/Dockerfile.bionic),
85-
which is based on Ubuntu.
86-
87-
<br>
88-
89-
## TypeScript IDE support
90-
91-
Playwright comes with built-in support for TypeScript. Playwright type definitions will be imported automatically.
71+
```
72+
npx playwright-cli codegen wikipedia.org
73+
```
9274

93-
It is also possible to add these types to your variables manually. In TypeScript:
75+
## TypeScript support
9476

95-
```ts
96-
let page: import('playwright').Page;
97-
```
77+
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.
9878

99-
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:
79+
### In JavaScript
80+
Add the following to the top of your JavaScript file to get type-checking in VS Code or WebStorm.
10081

10182
```js
10283
//@ts-check
10384
// ...
10485
```
10586

106-
You can also use JSDoc to set types for variables.
87+
Alternatively, you can use JSDoc to set types for variables.
10788

10889
```js
10990
/** @type {import('playwright').Page} */
11091
let page;
11192
```
93+
94+
### In TypeScript
95+
TypeScript support will work out-of-the-box. Types can also be imported explicitly.
96+
97+
```ts
98+
let page: import('playwright').Page;
99+
```
100+
101+
## System requirements
102+
103+
Playwright requires Node.js version 10.17 or above. The browser binaries for Chromium,
104+
Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):
105+
106+
* **Windows**: Works with Windows and Windows Subsystem for Linux (WSL).
107+
* **macOS**: Requires 10.14 or above.
108+
* **Linux**: Depending on your Linux distribution, you might need to install additional
109+
dependencies to run the browsers.
110+
* Firefox requires Ubuntu 18.04+
111+
* For Ubuntu 18.04, the additional dependencies are defined in [our Docker image](docker/Dockerfile.bionic),
112+
which is based on Ubuntu.

0 commit comments

Comments
 (0)