
import asyncio
from pathlib import Path
from playwright.async_api import async_playwright

async def main():
    root = Path(__file__).resolve().parents[1]
    html = (root/'actual_dashboard_render_rc15.html').read_text(encoding='utf-8')
    async with async_playwright() as pw:
        browser = await pw.chromium.launch(
            headless=True,
            executable_path='/usr/bin/chromium',
            args=['--no-sandbox','--disable-dev-shm-usage','--disable-gpu','--disable-gpu-sandbox','--use-gl=swiftshader','--enable-unsafe-swiftshader','--allow-file-access-from-files']
        )
        page = await browser.new_page(viewport={'width':1180,'height':820}, device_scale_factor=1)
        await page.set_content(html, wait_until='load')
        await page.wait_for_timeout(3500)
        await page.screenshot(path=str(root/'docs'/'QA_v96_RC15_dashboard_unframed_ipad_landscape.png'), full_page=False)
        page2 = await browser.new_page(viewport={'width':430,'height':932}, device_scale_factor=1)
        await page2.set_content(html, wait_until='load')
        await page2.wait_for_timeout(3500)
        await page2.screenshot(path=str(root/'docs'/'QA_v96_RC15_dashboard_unframed_mobile.png'), full_page=False)
        await browser.close()

asyncio.run(main())
