diff --git a/scripts/playwright/cookie_param_models/image01.py b/scripts/playwright/cookie_param_models/image01.py index 77c91bfe22..a8cf3d1bf1 100644 --- a/scripts/playwright/cookie_param_models/image01.py +++ b/scripts/playwright/cookie_param_models/image01.py @@ -10,8 +10,6 @@ def run(playwright: Playwright) -> None: browser = playwright.chromium.launch(headless=False) # Update the viewport manually context = browser.new_context(viewport={"width": 960, "height": 1080}) - browser = playwright.chromium.launch(headless=False) - context = browser.new_context() page = context.new_page() page.goto("http://localhost:8000/docs") page.get_by_role("link", name="/items/").click() @@ -27,12 +25,13 @@ process = subprocess.Popen( ["fastapi", "run", "docs_src/cookie_param_models/tutorial001.py"] ) try: - for _ in range(3): + for _ in range(10): try: response = httpx.get("http://localhost:8000/docs") + if response.status_code == 200: + break except httpx.ConnectError: time.sleep(1) - break with sync_playwright() as playwright: run(playwright) finally: diff --git a/scripts/playwright/header_param_models/image01.py b/scripts/playwright/header_param_models/image01.py index 53914251ed..8a41c3825b 100644 --- a/scripts/playwright/header_param_models/image01.py +++ b/scripts/playwright/header_param_models/image01.py @@ -26,12 +26,13 @@ process = subprocess.Popen( ["fastapi", "run", "docs_src/header_param_models/tutorial001.py"] ) try: - for _ in range(3): + for _ in range(10): try: response = httpx.get("http://localhost:8000/docs") + if response.status_code == 200: + break except httpx.ConnectError: time.sleep(1) - break with sync_playwright() as playwright: run(playwright) finally: diff --git a/scripts/playwright/json_base64_bytes/image01.py b/scripts/playwright/json_base64_bytes/image01.py index 56c57e1c32..1d3fada5b2 100644 --- a/scripts/playwright/json_base64_bytes/image01.py +++ b/scripts/playwright/json_base64_bytes/image01.py @@ -25,12 +25,13 @@ process = subprocess.Popen( ["fastapi", "run", "docs_src/json_base64_bytes/tutorial001_py310.py"] ) try: - for _ in range(3): + for _ in range(10): try: response = httpx.get("http://localhost:8000/docs") + if response.status_code == 200: + break except httpx.ConnectError: time.sleep(1) - break with sync_playwright() as playwright: run(playwright) finally: diff --git a/scripts/playwright/query_param_models/image01.py b/scripts/playwright/query_param_models/image01.py index 0ea1d0df4e..157ac4ef52 100644 --- a/scripts/playwright/query_param_models/image01.py +++ b/scripts/playwright/query_param_models/image01.py @@ -10,8 +10,6 @@ def run(playwright: Playwright) -> None: browser = playwright.chromium.launch(headless=False) # Update the viewport manually context = browser.new_context(viewport={"width": 960, "height": 1080}) - browser = playwright.chromium.launch(headless=False) - context = browser.new_context() page = context.new_page() page.goto("http://localhost:8000/docs") page.get_by_role("button", name="GET /items/ Read Items").click() @@ -29,12 +27,13 @@ process = subprocess.Popen( ["fastapi", "run", "docs_src/query_param_models/tutorial001.py"] ) try: - for _ in range(3): + for _ in range(10): try: response = httpx.get("http://localhost:8000/docs") + if response.status_code == 200: + break except httpx.ConnectError: time.sleep(1) - break with sync_playwright() as playwright: run(playwright) finally: diff --git a/scripts/playwright/request_form_models/image01.py b/scripts/playwright/request_form_models/image01.py index fe4da32fcb..ec4472ec3e 100644 --- a/scripts/playwright/request_form_models/image01.py +++ b/scripts/playwright/request_form_models/image01.py @@ -26,12 +26,13 @@ process = subprocess.Popen( ["fastapi", "run", "docs_src/request_form_models/tutorial001.py"] ) try: - for _ in range(3): + for _ in range(10): try: response = httpx.get("http://localhost:8000/docs") + if response.status_code == 200: + break except httpx.ConnectError: time.sleep(1) - break with sync_playwright() as playwright: run(playwright) finally: diff --git a/scripts/playwright/sql_databases/image01.py b/scripts/playwright/sql_databases/image01.py index 0dd6f25145..0490d621a0 100644 --- a/scripts/playwright/sql_databases/image01.py +++ b/scripts/playwright/sql_databases/image01.py @@ -25,12 +25,13 @@ process = subprocess.Popen( ["fastapi", "run", "docs_src/sql_databases/tutorial001.py"], ) try: - for _ in range(3): + for _ in range(10): try: response = httpx.get("http://localhost:8000/docs") + if response.status_code == 200: + break except httpx.ConnectError: time.sleep(1) - break with sync_playwright() as playwright: run(playwright) finally: diff --git a/scripts/playwright/sql_databases/image02.py b/scripts/playwright/sql_databases/image02.py index 6c4f685e86..ff134b2c4a 100644 --- a/scripts/playwright/sql_databases/image02.py +++ b/scripts/playwright/sql_databases/image02.py @@ -25,12 +25,13 @@ process = subprocess.Popen( ["fastapi", "run", "docs_src/sql_databases/tutorial002.py"], ) try: - for _ in range(3): + for _ in range(10): try: response = httpx.get("http://localhost:8000/docs") + if response.status_code == 200: + break except httpx.ConnectError: time.sleep(1) - break with sync_playwright() as playwright: run(playwright) finally: