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

async def main():
    root=Path(__file__).resolve().parents[1]
    html=(root/'passview_image_test.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',
                '--disable-dev-shm-usage',
                '--disable-gpu',
                '--disable-gpu-compositing',
                '--disable-software-rasterizer',
                '--disable-features=VizDisplayCompositor,UseSkiaRenderer',
                '--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(5500)
        await page.screenshot(path=str(root/'docs'/'QA_v96_RC10_passview_image_test.png'), full_page=False)
        await browser.close()

asyncio.run(main())
