File size: 1,218 Bytes
6fff8e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 版面自检:python3 check.py l|p [step] [from] [to]
import sys, asyncio, json
from playwright.async_api import async_playwright
BASE = "http://localhost:5173/preview/production/1b822e06-b78d-4352-884d-1f8fddabf546/"
async def main():
    o = sys.argv[1]; step = sys.argv[2] if len(sys.argv) > 2 else '0.5'
    fr = sys.argv[3] if len(sys.argv) > 3 else '0'; to = sys.argv[4] if len(sys.argv) > 4 else '9999'
    async with async_playwright() as p:
        b = await p.chromium.launch()
        pg = await b.new_page()
        errs = []
        pg.on("pageerror", lambda e: errs.append(str(e)))
        pg.on("console", lambda m: errs.append(m.text) if m.type == "error" else None)
        await pg.goto(f"{BASE}?still=check&o={o}&w=960&step={step}&from={fr}&to={to}")
        try:
            await pg.wait_for_function("document.title==='ready'", timeout=590000, polling=1000)
        except Exception as e:
            print("TIMEOUT", e)
        rep = await pg.evaluate("window.REPORT || {}")
        for k, v in sorted(rep.items(), key=lambda kv: kv[1]['first']):
            print(f"{v['first']:7.1f} x{v['n']:<4} {k}")
        for e in errs[:10]: print("ERR", e)
        await b.close()
asyncio.run(main())