mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
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
|
webkit = playwright.webkit
|
||||||
browser = await webkit.launch()
|
browser = await webkit.launch()
|
||||||
page = await browser.new_page()
|
page = await browser.new_page()
|
||||||
watch_dog = asyncio.create_task(page.main_frame.wait_for_function("() => window.innerWidth < 100")
|
await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
|
||||||
await page.set_viewport_size({"width": 50, "height": 50})
|
await page.main_frame.wait_for_function("() => window.x > 0")
|
||||||
await watch_dog
|
|
||||||
await browser.close()
|
await browser.close()
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
@ -1057,6 +1056,21 @@ async def main():
|
|||||||
asyncio.run(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:
|
To pass an argument to the predicate of `frame.waitForFunction` function:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
@ -2209,9 +2209,8 @@ async def run(playwright):
|
|||||||
webkit = playwright.webkit
|
webkit = playwright.webkit
|
||||||
browser = await webkit.launch()
|
browser = await webkit.launch()
|
||||||
page = await browser.new_page()
|
page = await browser.new_page()
|
||||||
watch_dog = page.wait_for_function("() => window.innerWidth < 100")
|
await page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
|
||||||
await page.set_viewport_size({"width": 50, "height": 50})
|
await page.wait_for_function("() => window.x > 0")
|
||||||
await watch_dog
|
|
||||||
await browser.close()
|
await browser.close()
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
@ -2225,12 +2224,11 @@ from playwright.sync_api import sync_playwright
|
|||||||
|
|
||||||
def run(playwright):
|
def run(playwright):
|
||||||
webkit = playwright.webkit
|
webkit = playwright.webkit
|
||||||
browser = await webkit.launch()
|
browser = webkit.launch()
|
||||||
page = await browser.new_page()
|
page = browser.new_page()
|
||||||
watch_dog = page.wait_for_function("() => window.innerWidth < 100")
|
page.evaluate("window.x = 0; setTimeout(() => { window.x = 100 }, 1000);", force_expr=True)
|
||||||
await page.set_viewport_size({"width": 50, "height": 50})
|
page.wait_for_function("() => window.x > 0")
|
||||||
await watch_dog
|
browser.close()
|
||||||
await browser.close()
|
|
||||||
|
|
||||||
with sync_playwright() as playwright:
|
with sync_playwright() as playwright:
|
||||||
run(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(/\[[^\]]+\]:/);
|
const bothLinks = node.text.match(/\[[^\]]+\]:/) && lastNode && lastNode.type === 'text' && lastNode.text.match(/\[[^\]]+\]:/);
|
||||||
if (!bothTables && !bothGen && !bothComments && !bothLinks && lastNode && lastNode.text)
|
if (!bothTables && !bothGen && !bothComments && !bothLinks && lastNode && lastNode.text)
|
||||||
newLine();
|
newLine();
|
||||||
result.push(wrapText(node.text, maxColumns, indent));
|
for (const line of node.text.split('\n'))
|
||||||
|
result.push(wrapText(line, maxColumns, indent));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user