"""截图追加后看板"""
import asyncio
from playwright.async_api import async_playwright
import os, sys
sys.stdout.reconfigure(encoding='utf-8')
BASE = os.path.dirname(os.path.abspath(__file__))
URL = 'http://localhost:8899/dashboard.html'

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=True)
        page = await browser.new_page(viewport={'width': 1400, 'height': 950})
        await page.goto(URL, wait_until='networkidle')
        await asyncio.sleep(3)
        await page.screenshot(path=os.path.join(BASE, 'ss_append.png'), full_page=True)
        print('ss_append.png')
        kpi = await page.text_content('#kpi')
        info = await page.text_content('#info')
        print(f'Info: {info}')
        await browser.close()

asyncio.run(main())
