|
5 | 5 | - [Usage](#usage) |
6 | 6 | - [First script](#first-script) |
7 | 7 | - [System requirements](#system-requirements) |
| 8 | +- [TypeScript IDE support](#typescript-ide-support) |
8 | 9 | - [Debugging scripts](#debugging-scripts) |
| 10 | + * [Using editor debugger](#using-editor-debugger) |
| 11 | + * [Verbose logging](#verbose-logging) |
9 | 12 | <!-- GEN:stop --> |
10 | 13 |
|
11 | 14 | <br> |
@@ -80,17 +83,57 @@ Firefox and WebKit work across the 3 platforms (Windows, macOS, Linux): |
80 | 83 | * **macOS**: Requires 10.14 or above. |
81 | 84 | * **Linux**: Depending on your Linux distribution, you might need to install additional |
82 | 85 | dependencies to run the browsers. |
| 86 | + * Firefox requires Ubuntu 18.04+ |
83 | 87 | * For Ubuntu 18.04, the additional dependencies are defined in [our Docker image](docker/Dockerfile.bionic), |
84 | 88 | which is based on Ubuntu. |
85 | 89 |
|
86 | 90 | <br> |
87 | 91 |
|
| 92 | +## TypeScript IDE support |
| 93 | + |
| 94 | +Playwright comes with built-in support for TypeScript. Playwright type definitions will be imported automatically. |
| 95 | + |
| 96 | +It is also possible to add these types to your variables manually. In TypeScript: |
| 97 | + |
| 98 | +```ts |
| 99 | +let page: import('playwright').Page; |
| 100 | +``` |
| 101 | + |
| 102 | +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: |
| 103 | + |
| 104 | +```js |
| 105 | +//@ts-check |
| 106 | +// ... |
| 107 | +``` |
| 108 | + |
| 109 | +You can also use JSDoc to set types for variables. |
| 110 | + |
| 111 | +```js |
| 112 | +/** @type {import('playwright').Page} */ |
| 113 | +let page; |
| 114 | +``` |
| 115 | + |
| 116 | +<br> |
| 117 | + |
88 | 118 | ## Debugging scripts |
89 | 119 |
|
| 120 | +### Using editor debugger |
| 121 | + |
90 | 122 | 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. |
91 | 123 |
|
92 | 124 | <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> |
93 | 125 |
|
94 | 126 | It is also possible to open **browser developer tools** during execution, to inspect the DOM tree or network activity. |
95 | 127 |
|
96 | | -<br> |
| 128 | +### Verbose logging |
| 129 | + |
| 130 | +Playwright supports verbose logging with the `DEBUG` environment variable. |
| 131 | + |
| 132 | +```sh |
| 133 | +# Linux/macOS |
| 134 | +$ DEBUG=pw:api npm run test |
| 135 | + |
| 136 | +# Windows |
| 137 | +$ set DEBUG=pw:api |
| 138 | +$ npm run test |
| 139 | +``` |
0 commit comments