Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: prepare docs for tabbed snippets #5026

Merged
merged 1 commit into from Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions docs/src/api/class-frame.md
Expand Up @@ -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():
Expand All @@ -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
Expand Down
16 changes: 7 additions & 9 deletions docs/src/api/class-page.md
Expand Up @@ -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():
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion utils/markdown.js
Expand Up @@ -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;
}

Expand Down