Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
- [Usage](#usage)
- [First script](#first-script)
- [System requirements](#system-requirements)
- [TypeScript IDE support](#typescript-ide-support)
- [Debugging scripts](#debugging-scripts)
* [Using editor debugger](#using-editor-debugger)
* [Verbose logging](#verbose-logging)
<!-- GEN:stop -->

<br>
Expand Down Expand Up @@ -80,17 +83,57 @@ Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):
* **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.

It is also possible to add these types to your variables manually. In TypeScript:

```ts
let page: import('playwright').Page;
```

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:

```js
//@ts-check
// ...
```

You can also use JSDoc to set types for variables.

```js
/** @type {import('playwright').Page} */
let page;
```

<br>

## Debugging scripts

### Using editor debugger

Playwright scripts can be developed just like any other Node.js script. For example, you can use the [Node.js debugger](https://nodejs.org/api/debugger.html) or [VS Code debugging](https://code.visualstudio.com/docs/nodejs/nodejs-debugging) to set breakpoints and get fine grained control over execution.

<a href="https://user-images.githubusercontent.com/284612/77234134-5f21a500-6b69-11ea-92ec-1c146e1333ec.png"><img src="https://user-images.githubusercontent.com/284612/77234134-5f21a500-6b69-11ea-92ec-1c146e1333ec.png" width="300" alt="Chromium Developer Tools"></a>

It is also possible to open **browser developer tools** during execution, to inspect the DOM tree or network activity.

<br>
### Verbose logging

Playwright supports verbose logging with the `DEBUG` environment variable.

```sh
# Linux/macOS
$ DEBUG=pw:api npm run test

# Windows
$ set DEBUG=pw:api
$ npm run test
```
14 changes: 0 additions & 14 deletions docs/test-runners.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ With a few lines of code, you can hook up Playwright to your favorite JavaScript
- [Jest / Jasmine](#jest--jasmine)
- [AVA](#ava)
- [Mocha](#mocha)
- [IDE support](#ide-support)
- [Multiple Browsers](#multiple-browsers)
<!-- GEN:stop -->

Expand Down Expand Up @@ -98,19 +97,6 @@ it('should work', async () => {
```
<br>

## IDE support

If using TypeScript, add types to your variables like:
```ts
let page: import('playwright').Page;
```

If using JavaScript, you can still get nice autocompletions in VSCode or WebStorm by using JSDoc.
```js
/** @type {import('playwright').Page} */
let page;
```

## Multiple Browsers

These simple examples can be extended to support multiple browsers using an environment variable.
Expand Down