Debian Codegraph @

scripts/playwright/separate_openapi_schemas/image03.py

raw
1 import subprocess
2
3 from playwright.sync_api import Playwright, sync_playwright
4
5
6 # Run playwright codegen to generate the code below, copy paste the sections in run()
7 def run(playwright: Playwright) -> None:
8 browser = playwright.chromium.launch(headless=False)
9 # Update the viewport manually
10 context = browser.new_context(viewport={"width": 960, "height": 1080})
11 page = context.new_page()
12 page.goto("http://localhost:8000/docs")
13 page.get_by_text("GET/items/Read Items").click()
14 page.get_by_role("tab", name="Schema").click()
15 page.get_by_label("Schema").get_by_role("button", name="Expand all").click()
16 # Manually add the screenshot
17 page.screenshot(
18 path="docs/en/docs/img/tutorial/separate-openapi-schemas/image03.png"
19 )
20
21 # ---------------------
22 context.close()
23 browser.close()
24
25
26 process = subprocess.Popen(
27 ["uvicorn", "docs_src.separate_openapi_schemas.tutorial001:app"]
28 )
29 try:
30 with sync_playwright() as playwright:
31 run(playwright)
32 finally:
33 process.terminate()