diff --git a/docs/src/api/class-frame.md b/docs/src/api/class-frame.md index c660e9140f731..1bf04d1d10274 100644 --- a/docs/src/api/class-frame.md +++ b/docs/src/api/class-frame.md @@ -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 diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md index 91ae120eca259..63432c9304e37 100644 --- a/docs/src/api/class-page.md +++ b/docs/src/api/class-page.md @@ -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) diff --git a/utils/markdown.js b/utils/markdown.js index a1203d775f7bc..4b30e96687ca4 100644 --- a/utils/markdown.js +++ b/utils/markdown.js @@ -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; }