docs: using DEBUG=pw:api (#2578)
This commit is contained in:
parent
1c7a8952b9
commit
1bc04a088b
|
|
@ -5,7 +5,10 @@
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [First script](#first-script)
|
- [First script](#first-script)
|
||||||
- [System requirements](#system-requirements)
|
- [System requirements](#system-requirements)
|
||||||
|
- [TypeScript IDE support](#typescript-ide-support)
|
||||||
- [Debugging scripts](#debugging-scripts)
|
- [Debugging scripts](#debugging-scripts)
|
||||||
|
* [Using editor debugger](#using-editor-debugger)
|
||||||
|
* [Verbose logging](#verbose-logging)
|
||||||
<!-- GEN:stop -->
|
<!-- GEN:stop -->
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
@ -80,17 +83,57 @@ Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux):
|
||||||
* **macOS**: Requires 10.14 or above.
|
* **macOS**: Requires 10.14 or above.
|
||||||
* **Linux**: Depending on your Linux distribution, you might need to install additional
|
* **Linux**: Depending on your Linux distribution, you might need to install additional
|
||||||
dependencies to run the browsers.
|
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),
|
* For Ubuntu 18.04, the additional dependencies are defined in [our Docker image](docker/Dockerfile.bionic),
|
||||||
which is based on Ubuntu.
|
which is based on Ubuntu.
|
||||||
|
|
||||||
<br>
|
<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
|
## 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.
|
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>
|
<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.
|
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
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ With a few lines of code, you can hook up Playwright to your favorite JavaScript
|
||||||
- [Jest / Jasmine](#jest--jasmine)
|
- [Jest / Jasmine](#jest--jasmine)
|
||||||
- [AVA](#ava)
|
- [AVA](#ava)
|
||||||
- [Mocha](#mocha)
|
- [Mocha](#mocha)
|
||||||
- [IDE support](#ide-support)
|
|
||||||
- [Multiple Browsers](#multiple-browsers)
|
- [Multiple Browsers](#multiple-browsers)
|
||||||
<!-- GEN:stop -->
|
<!-- GEN:stop -->
|
||||||
|
|
||||||
|
|
@ -98,19 +97,6 @@ it('should work', async () => {
|
||||||
```
|
```
|
||||||
<br>
|
<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
|
## Multiple Browsers
|
||||||
|
|
||||||
These simple examples can be extended to support multiple browsers using an environment variable.
|
These simple examples can be extended to support multiple browsers using an environment variable.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue