Explorer
/tmp/p6_browser.py
← Zurück ↓ Download
import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        b=await p.chromium.launch(headless=True, executable_path='/snap/bin/chromium', args=['--no-sandbox'])
        page=await b.new_page(viewport={'width':1440,'height':1000})
        checks={}
        for name,url,need in [
            ('alle','/cockpit?days=0&sort=op_priority&tab=radar','META AD'),
            ('fb14','/cockpit?days=14&sort=facebook&tab=radar','META AD'),
            ('li14','/cockpit?days=14&sort=linkedin&tab=radar',''),
        ]:
            r=await page.goto('http://127.0.0.1:8652'+url,wait_until='domcontentloaded',timeout=30000)
            await page.wait_for_timeout(500)
            text=await page.locator('body').inner_text()
            checks[name]={'status':r.status,'need':(need in text if need else True),'cards':await page.locator('.sig').count(),'filter_labels':all(x in text for x in ['Priorität ↓','Score ↓','Neu ↓','Viral ↓'])}
            await page.screenshot(path='/tmp/p6_'+name+'.png',full_page=True)
        await page.goto('http://127.0.0.1:8652/cockpit?days=14&sort=facebook&tab=radar',wait_until='domcontentloaded')
        await page.wait_for_timeout(300)
        thumb=page.locator('.sig .thumb').first
        if await thumb.count():
            await thumb.click()
            await page.wait_for_timeout(100)
            checks['detail_panel']=await page.locator('#pcontent.on').count() == 1
        else: checks['detail_panel']=False
        print(checks)
        await b.close()
asyncio.run(main())