
import asyncio
from pathlib import Path
from playwright.async_api import async_playwright
async def main():
    root = Path(__file__).resolve().parents[1]
    html = (root/'preview.html').read_text(encoding='utf-8')
    html = html.replace('<head>', '<head><base href="file://' + str(root).replace('\\','/') + '/">', 1)
    async with async_playwright() as pw:
        browser = await pw.chromium.launch(headless=True, executable_path='/usr/bin/chromium', args=['--no-sandbox', '--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(2500)
        await page.screenshot(path=str(root/'docs'/'QA_v96_RC9_dashboard_render.png'), full_page=False)
        await browser.close()
asyncio.run(main())
