Explorer
/tmp/verify_browser.py
← Zurück ↓ Download
import asyncio, json, re
from pathlib import Path
from playwright.async_api import async_playwright

BASE='https://sma.agentsolutions-mallorca.com'
REAL='41222120-fb41-4fb1-ad14-c8a873b9a0a4'

async def main():
    async with async_playwright() as pw:
        browser=await pw.chromium.launch(headless=True, executable_path='/snap/bin/chromium', args=['--no-sandbox'])
        page=await browser.new_page()
        results={}
        for days,label in [(1,'HEUTE'),(2,'2T'),(3,'3T'),(7,'7T'),(14,'14T')]:
            response=await page.goto(f'{BASE}/cockpit?days={days}', wait_until='networkidle', timeout=60000)
            cards=await page.locator('.sig').count()
            results[label]={'http':response.status if response else None,'cards':cards,'title':await page.title()}
        response=await page.goto(f'{BASE}/cockpit?days=14&highlight={REAL}', wait_until='networkidle', timeout=60000)
        results['real_deep_link']={
            'http':response.status if response else None,
            'card_present':await page.locator(f'#sig-{REAL}').count(),
            'panel_open':await page.locator('#pcontent.on').count(),
            'panel_contains_real_title':REAL in (await page.locator('#pcontent').inner_text()),
        }
        await page.screenshot(path='/tmp/aa045-f8-p2-cockpit-highlight.png', full_page=True)
        await page.goto(f'{BASE}/dashboard', wait_until='networkidle', timeout=60000)
        dashboard_text=await page.locator('body').inner_text()
        rows=await page.locator('.sig-row').count()
        first=await page.locator('.sig-row').first.get_attribute('onclick') if rows else None
        results['dashboard']={'http':200,'sig_rows':rows,'real_current_visible':REAL in dashboard_text,'first_deep_link':first}
        if first:
            m=re.search(r"highlight=([0-9a-f-]+)", first)
            if m:
                sid=m.group(1)
                await page.goto(f'{BASE}/cockpit?highlight={sid}', wait_until='networkidle', timeout=60000)
                results['dashboard_to_cockpit']={'sid':sid,'card_present':await page.locator(f'#sig-{sid}').count(),'panel_open':await page.locator('#pcontent.on').count()}
        print(json.dumps(results,ensure_ascii=False))
        await browser.close()

asyncio.run(main())