Skip to content

Commit 7a8214c

Browse files
authored
chore: prepare non-api docs for non-js variants (#4969)
1 parent 4dbbb47 commit 7a8214c

15 files changed

+439
-147
lines changed

docs/src/api/python.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ Performs action and waits for given `event` to fire. If predicate is provided, i
124124
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
125125
Will throw an error if the page is closed before the `event` is fired.
126126

127-
```python-async
127+
```python async
128128
async with page.expect_event(event_name) as event_info:
129129
await page.click("button")
130130
value = await event_info.value
131131
```
132132

133-
```python-sync
133+
```python sync
134134
with page.expect_event(event_name) as event_info:
135135
page.click("button")
136136
value = event_info.value
@@ -148,13 +148,13 @@ Performs action and waits for given `event` to fire. If predicate is provided, i
148148
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
149149
Will throw an error if browser context is closed before the `event` is fired.
150150

151-
```python-async
151+
```python async
152152
async with context.expect_event(event_name) as event_info:
153153
await context.click("button")
154154
value = await event_info.value
155155
```
156156

157-
```python-sync
157+
```python sync
158158
with context.expect_event(event_name) as event_info:
159159
context.click("button")
160160
value = event_info.value
@@ -172,13 +172,13 @@ Performs action and waits for given `event` to fire. If predicate is provided, i
172172
event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
173173
Will throw an error if the socket is closed before the `event` is fired.
174174

175-
```python-async
175+
```python async
176176
async with ws.expect_event(event_name) as event_info:
177177
await ws.click("button")
178178
value = await event_info.value
179179
```
180180

181-
```python-sync
181+
```python sync
182182
with ws.expect_event(event_name) as event_info:
183183
ws.click("button")
184184
value = event_info.value
@@ -195,13 +195,13 @@ value = event_info.value
195195
Performs action and waits for the required load state. It resolves when the page reaches a required load state, `load` by default. The navigation must have been committed when this method is called. If current document has
196196
already reached the required state, resolves immediately.
197197

198-
```python-async
198+
```python async
199199
async with page.expect_load_state():
200200
await page.click('button') # Click triggers navigation.
201201
# Context manager waits for 'load' event.
202202
```
203203

204-
```python-sync
204+
```python sync
205205
with page.expect_load_state():
206206
page.click('button') # Click triggers navigation.
207207
# Context manager waits for 'load' event.
@@ -219,13 +219,13 @@ Shortcut for main frame's [`method: Frame.expectLoadState`].
219219
Performs action and waits for the required load state. It resolves when the page reaches a required load state, `load` by default. The navigation must have been committed when this method is called. If current document has
220220
already reached the required state, resolves immediately.
221221

222-
```python-async
222+
```python async
223223
async with frame.expect_load_state():
224224
await frame.click('button') # Click triggers navigation.
225225
# Context manager waits for 'load' event.
226226
```
227227

228-
```python-sync
228+
```python sync
229229
with frame.expect_load_state():
230230
frame.click('button') # Click triggers navigation.
231231
# Context manager waits for 'load' event.
@@ -238,21 +238,21 @@ with frame.expect_load_state():
238238
* langs: python
239239
- returns: <[EventContextManager]>
240240

241-
Performs action and wait for the next navigation. In case of multiple redirects, the navigation will resolve with
241+
Performs action and waits for the next navigation. In case of multiple redirects, the navigation will resolve with
242242
the response of the last redirect. In case of navigation to a different anchor or navigation due to History API
243243
usage, the navigation will resolve with `null`.
244244

245245
This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will
246246
indirectly cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation
247247
from a `setTimeout`. Consider this example:
248248

249-
```python-async
249+
```python async
250250
async with page.expect_navigation():
251251
await page.click("a.delayed-navigation") # Clicking the link will indirectly cause a navigation
252252
# Context manager waited for the navigation to happen.
253253
```
254254

255-
```python-sync
255+
```python sync
256256
with page.expect_navigation():
257257
page.click("a.delayed-navigation") # Clicking the link will indirectly cause a navigation
258258
# Context manager waited for the navigation to happen.
@@ -271,21 +271,21 @@ Shortcut for main frame's [`method: Frame.expectNavigation`].
271271
* langs: python
272272
- returns: <[EventContextManager]>
273273

274-
Performs action and wait for the next navigation. In case of multiple redirects, the navigation will resolve with
274+
Performs action and waits for the next navigation. In case of multiple redirects, the navigation will resolve with
275275
the response of the last redirect. In case of navigation to a different anchor or navigation due to History API
276276
usage, the navigation will resolve with `null`.
277277

278278
This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will
279279
indirectly cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation
280280
from a `setTimeout`. Consider this example:
281281

282-
```python-async
282+
```python async
283283
async with frame.expect_navigation():
284284
await frame.click("a.delayed-navigation") # Clicking the link will indirectly cause a navigation
285285
# Context manager waited for the navigation to happen.
286286
```
287287

288-
```python-sync
288+
```python sync
289289
with frame.expect_navigation():
290290
frame.click("a.delayed-navigation") # Clicking the link will indirectly cause a navigation
291291
# Context manager waited for the navigation to happen.

docs/src/assertions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const checked = await page.getAttribute('input', 'checked');
3535
assert(checked);
3636
```
3737

38-
```python-async
38+
```python async
3939
# Assert text content
4040
content = await page.text_content('nav:first-child')
4141
assert content == 'home'
@@ -53,7 +53,7 @@ checked = await page.get_attribute('input', 'checked')
5353
assert checked
5454
```
5555

56-
```python-sync
56+
```python sync
5757
# Assert text content
5858
content = page.text_content('nav:first-child')
5959
assert content == 'home'
@@ -106,7 +106,7 @@ const classNames = await elementHandle.getAttribute('class');
106106
assert(classNames.includes('highlighted'));
107107
```
108108

109-
```python-async
109+
```python async
110110
# Get the element handle
111111
element_handle = page.wait_for_selector('#box')
112112

@@ -119,7 +119,7 @@ class_names = await element_handle.get_attribute('class')
119119
assert 'highlighted' in class_names
120120
```
121121

122-
```python-sync
122+
```python sync
123123
# Get the element handle
124124
element_handle = page.wait_for_selector('#box')
125125

@@ -171,7 +171,7 @@ const length = await page.$$eval('li.selected', (items) => items.length);
171171
assert(length === 3);
172172
```
173173

174-
```python-async
174+
```python async
175175
# Assert local storage value
176176
user_id = page.evaluate("() => window.localStorage.getItem('user_id')")
177177
assert user_id
@@ -190,7 +190,7 @@ length = await page.eval_on_selector_all('li.selected', '(items) => items.length
190190
assert length == 3
191191
```
192192

193-
```python-sync
193+
```python sync
194194
# Assert local storage value
195195
user_id = page.evaluate("() => window.localStorage.getItem('user_id')")
196196
assert user_id

docs/src/auth.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ await page.click('text=Submit');
3636
// Verify app is logged in
3737
```
3838

39-
```python-async
39+
```python async
4040
page = await context.new_page()
4141
await page.goto('https://github.com/login')
4242

@@ -48,7 +48,7 @@ await page.click('text=Submit')
4848
# Verify app is logged in
4949
```
5050

51-
```python-sync
51+
```python sync
5252
page = context.new_page()
5353
page.goto('https://github.com/login')
5454

@@ -88,7 +88,7 @@ const storageState = JSON.parse(process.env.STORAGE);
8888
const context = await browser.newContext({ storageState });
8989
```
9090

91-
```python-async
91+
```python async
9292
import json
9393
import os
9494
# Save storage state and store as an env variable
@@ -100,7 +100,7 @@ storage_state = json.loads(os.environ["STORAGE"])
100100
context = await browser.new_context(storage_state=storage_state)
101101
```
102102

103-
```python-sync
103+
```python sync
104104
import json
105105
import os
106106
# Save storage state and store as an env variable
@@ -134,7 +134,7 @@ await context.addInitScript(storage => {
134134
}, sessionStorage);
135135
```
136136

137-
```python-async
137+
```python async
138138
import os
139139
# Get session storage and store as env variable
140140
session_storage = await page.evaluate("() => JSON.stringify(sessionStorage)")
@@ -152,7 +152,7 @@ await context.add_init_script(storage => {
152152
}, session_storage)
153153
```
154154

155-
```python-sync
155+
```python sync
156156
import os
157157
# Get session storage and store as env variable
158158
session_storage = page.evaluate("() => JSON.stringify(sessionStorage)")
@@ -217,7 +217,7 @@ const context = await chromium.launchPersistentContext(userDataDir, { headless:
217217
// Execute login steps manually in the browser window
218218
```
219219

220-
```python-async
220+
```python async
221221
import asyncio
222222
from playwright import async_playwright
223223

@@ -230,7 +230,7 @@ async def main():
230230
asyncio.get_event_loop().run_until_complete(main())
231231
```
232232

233-
```python-sync
233+
```python sync
234234
from playwright import sync_playwright
235235

236236
with sync_playwright() as p:

docs/src/ci.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ Suggested configuration
5050
});
5151
```
5252

53-
```python-async
53+
```python async
5454
browser = await playwright.chromium.launch(
5555
args=['--disable-dev-shm-usage']
5656
)
5757
```
5858

59-
```python-sync
59+
```python sync
6060
browser = playwright.chromium.launch({
6161
args=['--disable-dev-shm-usage']
6262
})
@@ -203,11 +203,11 @@ const { chromium } = require('playwright');
203203
const browser = await chromium.launch({ chromiumSandbox: false });
204204
```
205205

206-
```python-async
206+
```python async
207207
browser = await playwright.chromium.launch(chromiumSandbox=False)
208208
```
209209

210-
```python-sync
210+
```python sync
211211
browser = playwright.chromium.launch(chromiumSandbox=False)
212212
```
213213

@@ -287,7 +287,7 @@ const { chromium } = require('playwright');
287287
const browser = await chromium.launch({ headless: false });
288288
```
289289

290-
```python-async
290+
```python async
291291
import asyncio
292292
from playwright import async_playwright
293293
@@ -299,7 +299,7 @@ async def main():
299299
asyncio.get_event_loop().run_until_complete(main())
300300
```
301301

302-
```python-sync
302+
```python sync
303303
from playwright import sync_playwright
304304
305305
with sync_playwright() as p:

0 commit comments

Comments
 (0)