docs: prepare docs for tabbed snippets (#5026)
This commit is contained in:
parent
56ba0b3cd9
commit
6e94c11034
|
@ -1046,9 +1046,8 @@ async def run(playwright):
|
|||
webkit = playwright.webkit
|
||||
browser = await webkit.launch()
|
||||
page = await browser.new_page()
|
||||
watch_dog = asyncio.create_task(page.main_frame.wait_for_function("() => window.innerWidth < 100")
|
||||
await page.set_viewport_size({"width": 50, "height": 50})
|
||||
await watch_dog
|
||||
await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
|
||||
await page.main_frame.wait_for_function("() => window.x > 0")
|
||||
await browser.close()
|
||||
|
||||
async def main():
|
||||
|
@ -1057,6 +1056,21 @@ async def main():
|
|||
asyncio.run(main())
|
||||
```
|
||||
|
||||
```python sync
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
def run(playwright):
|
||||
webkit = playwright.webkit
|
||||
browser = webkit.launch()
|
||||
page = browser.new_page()
|
||||
page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
|
||||
page.main_frame.wait_for_function("() => window.x > 0")
|
||||
browser.close()
|
||||
|
||||
with sync_playwright() as playwright:
|
||||
run(playwright)
|
||||
```
|
||||
|
||||
To pass an argument to the predicate of `frame.waitForFunction` function:
|
||||
|
||||
```js
|
||||
|
|
|
@ -2209,9 +2209,8 @@ async def run(playwright):
|
|||
webkit = playwright.webkit
|
||||
browser = await webkit.launch()
|
||||
page = await browser.new_page()
|
||||
watch_dog = page.wait_for_function("() => window.innerWidth < 100")
|
||||
await page.set_viewport_size({"width": 50, "height": 50})
|
||||
await watch_dog
|
||||
await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
|
||||
await page.wait_for_function("() => window.x > 0")
|
||||
await browser.close()
|
||||
|
||||
async def main():
|
||||
|
@ -2225,12 +2224,11 @@ from playwright.sync_api import sync_playwright
|
|||
|
||||
def run(playwright):
|
||||
webkit = playwright.webkit
|
||||
browser = await webkit.launch()
|
||||
page = await browser.new_page()
|
||||
watch_dog = page.wait_for_function("() => window.innerWidth < 100")
|
||||
await page.set_viewport_size({"width": 50, "height": 50})
|
||||
await watch_dog
|
||||
await browser.close()
|
||||
browser = webkit.launch()
|
||||
page = browser.new_page()
|
||||
page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
|
||||
page.wait_for_function("() => window.x > 0")
|
||||
browser.close()
|
||||
|
||||
with sync_playwright() as playwright:
|
||||
run(playwright)
|
||||
|
|
|
@ -247,7 +247,8 @@ function innerRenderMdNode(indent, node, lastNode, result, maxColumns) {
|
|||
const bothLinks = node.text.match(/\[[^\]]+\]:/) && lastNode && lastNode.type === 'text' && lastNode.text.match(/\[[^\]]+\]:/);
|
||||
if (!bothTables && !bothGen && !bothComments && !bothLinks && lastNode && lastNode.text)
|
||||
newLine();
|
||||
result.push(wrapText(node.text, maxColumns, indent));
|
||||
for (const line of node.text.split('\n'))
|
||||
result.push(wrapText(line, maxColumns, indent));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue