mirror of https://github.com/tiangolo/fastapi.git
💡 Add comments with instructions for Playwright screenshot scripts (#12193)
This commit is contained in:
parent
ed66d70513
commit
2a4351105e
|
|
@ -8,11 +8,13 @@ from playwright.sync_api import Playwright, sync_playwright
|
||||||
# Run playwright codegen to generate the code below, copy paste the sections in run()
|
# Run playwright codegen to generate the code below, copy paste the sections in run()
|
||||||
def run(playwright: Playwright) -> None:
|
def run(playwright: Playwright) -> None:
|
||||||
browser = playwright.chromium.launch(headless=False)
|
browser = playwright.chromium.launch(headless=False)
|
||||||
context = browser.new_context()
|
# Update the viewport manually
|
||||||
|
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
||||||
page = context.new_page()
|
page = context.new_page()
|
||||||
page.goto("http://localhost:8000/docs")
|
page.goto("http://localhost:8000/docs")
|
||||||
page.get_by_role("button", name="POST /login/ Login").click()
|
page.get_by_role("button", name="POST /login/ Login").click()
|
||||||
page.get_by_role("button", name="Try it out").click()
|
page.get_by_role("button", name="Try it out").click()
|
||||||
|
# Manually add the screenshot
|
||||||
page.screenshot(path="docs/en/docs/img/tutorial/request-form-models/image01.png")
|
page.screenshot(path="docs/en/docs/img/tutorial/request-form-models/image01.png")
|
||||||
|
|
||||||
# ---------------------
|
# ---------------------
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,16 @@ import subprocess
|
||||||
from playwright.sync_api import Playwright, sync_playwright
|
from playwright.sync_api import Playwright, sync_playwright
|
||||||
|
|
||||||
|
|
||||||
|
# Run playwright codegen to generate the code below, copy paste the sections in run()
|
||||||
def run(playwright: Playwright) -> None:
|
def run(playwright: Playwright) -> None:
|
||||||
browser = playwright.chromium.launch(headless=False)
|
browser = playwright.chromium.launch(headless=False)
|
||||||
|
# Update the viewport manually
|
||||||
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
||||||
page = context.new_page()
|
page = context.new_page()
|
||||||
page.goto("http://localhost:8000/docs")
|
page.goto("http://localhost:8000/docs")
|
||||||
page.get_by_text("POST/items/Create Item").click()
|
page.get_by_text("POST/items/Create Item").click()
|
||||||
page.get_by_role("tab", name="Schema").first.click()
|
page.get_by_role("tab", name="Schema").first.click()
|
||||||
|
# Manually add the screenshot
|
||||||
page.screenshot(
|
page.screenshot(
|
||||||
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image01.png"
|
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image01.png"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,17 @@ import subprocess
|
||||||
from playwright.sync_api import Playwright, sync_playwright
|
from playwright.sync_api import Playwright, sync_playwright
|
||||||
|
|
||||||
|
|
||||||
|
# Run playwright codegen to generate the code below, copy paste the sections in run()
|
||||||
def run(playwright: Playwright) -> None:
|
def run(playwright: Playwright) -> None:
|
||||||
browser = playwright.chromium.launch(headless=False)
|
browser = playwright.chromium.launch(headless=False)
|
||||||
|
# Update the viewport manually
|
||||||
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
||||||
page = context.new_page()
|
page = context.new_page()
|
||||||
page.goto("http://localhost:8000/docs")
|
page.goto("http://localhost:8000/docs")
|
||||||
page.get_by_text("GET/items/Read Items").click()
|
page.get_by_text("GET/items/Read Items").click()
|
||||||
page.get_by_role("button", name="Try it out").click()
|
page.get_by_role("button", name="Try it out").click()
|
||||||
page.get_by_role("button", name="Execute").click()
|
page.get_by_role("button", name="Execute").click()
|
||||||
|
# Manually add the screenshot
|
||||||
page.screenshot(
|
page.screenshot(
|
||||||
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image02.png"
|
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image02.png"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,17 @@ import subprocess
|
||||||
from playwright.sync_api import Playwright, sync_playwright
|
from playwright.sync_api import Playwright, sync_playwright
|
||||||
|
|
||||||
|
|
||||||
|
# Run playwright codegen to generate the code below, copy paste the sections in run()
|
||||||
def run(playwright: Playwright) -> None:
|
def run(playwright: Playwright) -> None:
|
||||||
browser = playwright.chromium.launch(headless=False)
|
browser = playwright.chromium.launch(headless=False)
|
||||||
|
# Update the viewport manually
|
||||||
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
||||||
page = context.new_page()
|
page = context.new_page()
|
||||||
page.goto("http://localhost:8000/docs")
|
page.goto("http://localhost:8000/docs")
|
||||||
page.get_by_text("GET/items/Read Items").click()
|
page.get_by_text("GET/items/Read Items").click()
|
||||||
page.get_by_role("tab", name="Schema").click()
|
page.get_by_role("tab", name="Schema").click()
|
||||||
page.get_by_label("Schema").get_by_role("button", name="Expand all").click()
|
page.get_by_label("Schema").get_by_role("button", name="Expand all").click()
|
||||||
|
# Manually add the screenshot
|
||||||
page.screenshot(
|
page.screenshot(
|
||||||
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image03.png"
|
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image03.png"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,17 @@ import subprocess
|
||||||
from playwright.sync_api import Playwright, sync_playwright
|
from playwright.sync_api import Playwright, sync_playwright
|
||||||
|
|
||||||
|
|
||||||
|
# Run playwright codegen to generate the code below, copy paste the sections in run()
|
||||||
def run(playwright: Playwright) -> None:
|
def run(playwright: Playwright) -> None:
|
||||||
browser = playwright.chromium.launch(headless=False)
|
browser = playwright.chromium.launch(headless=False)
|
||||||
|
# Update the viewport manually
|
||||||
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
||||||
page = context.new_page()
|
page = context.new_page()
|
||||||
page.goto("http://localhost:8000/docs")
|
page.goto("http://localhost:8000/docs")
|
||||||
page.get_by_role("button", name="Item-Input").click()
|
page.get_by_role("button", name="Item-Input").click()
|
||||||
page.get_by_role("button", name="Item-Output").click()
|
page.get_by_role("button", name="Item-Output").click()
|
||||||
page.set_viewport_size({"width": 960, "height": 820})
|
page.set_viewport_size({"width": 960, "height": 820})
|
||||||
|
# Manually add the screenshot
|
||||||
page.screenshot(
|
page.screenshot(
|
||||||
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image04.png"
|
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image04.png"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,16 @@ import subprocess
|
||||||
from playwright.sync_api import Playwright, sync_playwright
|
from playwright.sync_api import Playwright, sync_playwright
|
||||||
|
|
||||||
|
|
||||||
|
# Run playwright codegen to generate the code below, copy paste the sections in run()
|
||||||
def run(playwright: Playwright) -> None:
|
def run(playwright: Playwright) -> None:
|
||||||
browser = playwright.chromium.launch(headless=False)
|
browser = playwright.chromium.launch(headless=False)
|
||||||
|
# Update the viewport manually
|
||||||
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
context = browser.new_context(viewport={"width": 960, "height": 1080})
|
||||||
page = context.new_page()
|
page = context.new_page()
|
||||||
page.goto("http://localhost:8000/docs")
|
page.goto("http://localhost:8000/docs")
|
||||||
page.get_by_role("button", name="Item", exact=True).click()
|
page.get_by_role("button", name="Item", exact=True).click()
|
||||||
page.set_viewport_size({"width": 960, "height": 700})
|
page.set_viewport_size({"width": 960, "height": 700})
|
||||||
|
# Manually add the screenshot
|
||||||
page.screenshot(
|
page.screenshot(
|
||||||
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image05.png"
|
path="docs/en/docs/img/tutorial/separate-openapi-schemas/image05.png"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue