@@ -12,19 +12,19 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
12
12
13
13
Headless execution is supported for all browsers on all platforms.
14
14
15
- * [ Usage] ( #usage )
15
+ - [ Usage] ( #usage )
16
16
- [ Record and generate code] ( #record-and-generate-code )
17
17
- [ Sync API] ( #sync-api )
18
18
- [ Async API] ( #async-api )
19
19
- [ With pytest] ( #with-pytest )
20
20
- [ Interactive mode (REPL)] ( #interactive-mode-repl )
21
- * [ Examples] ( #examples )
21
+ - [ Examples] ( #examples )
22
22
- [ Mobile and geolocation] ( #mobile-and-geolocation )
23
23
- [ Evaluate JS in browser] ( #evaluate-js-in-browser )
24
24
- [ Intercept network requests] ( #intercept-network-requests )
25
- * [ Documentation] ( #documentation )
26
- * [ Is Playwright ready?] ( #is-playwright-ready )
27
- * [ Migration from the pre-release versions] ( #migration-from-the-pre-release-versions )
25
+ - [ Documentation] ( #documentation )
26
+ - [ Is Playwright ready?] ( #is-playwright-ready )
27
+ - [ Migration from the pre-release versions] ( #migration-from-the-pre-release-versions )
28
28
29
29
## Usage
30
30
@@ -66,8 +66,11 @@ with sync_playwright() as p:
66
66
#### Async API
67
67
68
68
If you app is based on the modern asyncio loop and you are used to async/await constructs,
69
- Playwright exposes Async API for you. You should also use this API inside the Jupyter Notebook
70
- and other REPL frameworks that are already based on asyncio.
69
+ Playwright exposes Async API for you. You should use this API inside a Python REPL supporting ` asyncio ` like with ` python -m asyncio `
70
+
71
+ ``` console
72
+ $ python -m asyncio
73
+ ```
71
74
72
75
``` py
73
76
import asyncio
@@ -115,7 +118,11 @@ Blocking REPL, as in CLI:
115
118
>> > playwright.stop()
116
119
```
117
120
118
- Async REPL such as Jupyter Notebook:
121
+ Async REPL such as ` asyncio ` REPL:
122
+
123
+ ``` console
124
+ $ python -m asyncio
125
+ ```
119
126
120
127
``` py
121
128
>> > from playwright.async_api import async_playwright
@@ -178,6 +185,7 @@ async def main():
178
185
179
186
asyncio.run(main())
180
187
```
188
+
181
189
</details >
182
190
183
191
#### Evaluate JS in browser
@@ -201,6 +209,7 @@ with sync_playwright() as p:
201
209
print (dimensions)
202
210
browser.close()
203
211
```
212
+
204
213
<details >
205
214
<summary >Async variant</summary >
206
215
@@ -225,6 +234,7 @@ async def main():
225
234
226
235
asyncio.run(main())
227
236
```
237
+
228
238
</details >
229
239
230
240
#### Intercept network requests
@@ -248,6 +258,7 @@ with sync_playwright() as p:
248
258
page.goto(" http://todomvc.com" )
249
259
browser.close()
250
260
```
261
+
251
262
<details >
252
263
<summary >Async variant</summary >
253
264
@@ -271,6 +282,7 @@ async def main():
271
282
272
283
asyncio.run(main())
273
284
```
285
+
274
286
</details >
275
287
276
288
## Documentation
@@ -288,12 +300,14 @@ every release, but we promise to not break it anymore!
288
300
## Migration from the pre-release versions
289
301
290
302
The API has changed since the last 0.170.0 version:
303
+
291
304
- Snake case notation for methods and arguments:
292
305
293
306
``` py
294
307
# old
295
308
browser.newPage()
296
309
```
310
+
297
311
``` py
298
312
# new
299
313
browser.new_page()
0 commit comments