Browse Source
🐛 Fix Playwright scripts: server readiness check and duplicate browser launch
- Fix inverted retry logic in httpx readiness check: break on success instead of on ConnectError
- Increase retry count from 3 to 10 for more reliable server startup wait
- Remove duplicate browser launch and context overwrite in cookie_param_models and query_param_models scripts, preserving the intended 960x1080 viewport
pull/15399/head
yangxiangwen
2 months ago
Failed to extract signature
7 changed files with
21 additions and
18 deletions
scripts/playwright/cookie_param_models/image01.py
scripts/playwright/header_param_models/image01.py
scripts/playwright/json_base64_bytes/image01.py
scripts/playwright/query_param_models/image01.py
scripts/playwright/request_form_models/image01.py
scripts/playwright/sql_databases/image01.py
scripts/playwright/sql_databases/image02.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 :
@ -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 :
@ -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 :
@ -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 :
@ -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 :
@ -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 :
@ -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 :