
import asyncio
from playwright.async_api import async_playwright

async def shot():
    async with async_playwright() as p:
        br = await p.chromium.launch(channel='msedge', headless=True)
        pg = await br.new_page(viewport={'width':1536,'height':864})
        await pg.goto('http://localhost:8090/DOZIKWORKS_OS_v5_locked.dc.html')
        print('로딩 대기 45초...')
        await pg.wait_for_timeout(45000)
        # 콘솔 에러 체크
        errs = []
        pg.on('console', lambda m: errs.append(m.text) if m.type=='error' else None)
        await pg.wait_for_timeout(3000)
        await pg.screenshot(path='locked_front.png')
        print('front 저장')
        # 카메라 위에서 보기
        await pg.evaluate("(()=>{ const a=window.__dzw; if(a&&a.orbit){a.orbit.phi=0.05;a.orbit.r=6;a.updateCam();}})()")
        await pg.wait_for_timeout(1000)
        await pg.screenshot(path='locked_top.png')
        print('top 저장')
        await br.close()
        print('에러 수:', len(errs))
        if errs: print('첫 에러:', errs[0][:100])

asyncio.run(shot())
