Smail/test/tools/check_page.py
smail f265cc62f5
Some checks are pending
Security Checks / security (push) Waiting to run
补充云端验收证据并加固测试凭据检查
2026-09-21 00:21:50 +08:00

21 lines
798 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from playwright.sync_api import sync_playwright
import os
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.on('console', lambda msg: print(f'控制台类型:{msg.type}'))
page.on('pageerror', lambda exc: print(f'页面错误类型:{type(exc).__name__}'))
response = page.goto(os.environ['SMAIL_TEST_URL'])
print('状态码:', response.status)
content = page.content()
print('页面长度:', len(content))
next_btn = page.locator('#next')
print('下一步按钮数量:', next_btn.count())
buttons = page.locator('button')
print('按钮总数:', buttons.count())
for i in range(buttons.count()):
print(f'按钮 {i}:{buttons.nth(i).inner_text()}')
browser.close()