import asyncio, json from playwright.async_api import async_playwright async def main(): async with async_playwright() as p: b = await p.chromium.launch(args=["--no-sandbox"]) pg = await b.new_page(viewport={"width": 1440, "height": 950}) errs = [] pg.on("pageerror", lambda e: errs.append(str(e))) await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000) await pg.wait_for_timeout(3000) # 1) Add routines via the real UI await pg.click('#tabs button[data-view="tasks"]') await pg.wait_for_timeout(1200) await pg.evaluate("""() => { document.querySelectorAll('.routine-check').forEach(c=>c.checked=false); const all=[...document.querySelectorAll('.routine-check')]; [0,1,2,3].forEach(i=>{ if(all[i]) all[i].checked=true; }); // 4 daily routines }""") await pg.click('button[onclick="addRoutinesToToday()"]') await pg.wait_for_timeout(2000) stored = await pg.evaluate("() => tasks.filter(x=>x.cat==='routine').map(x=>({t:x.title,d:x.date}))") print("STORED:", json.dumps(stored, ensure_ascii=False)) # 2) Calendar must show them on today await pg.click('#tabs button[data-view="calendar"]') await pg.wait_for_timeout(1800) cal = await pg.evaluate("""() => { const days=[...document.querySelectorAll('.day')]; const today=days.find(d=>d.className.includes('today')); if(!today) return {found:false}; const tags=[...today.querySelectorAll('.tag')].map(t=>t.innerText.trim()); return {found:true, dayLabel: today.querySelector('.day-num')?.innerText, tagCount: tags.length, tags: tags.slice(0,6)}; }""") print("\nCALENDAR TODAY:", json.dumps(cal, ensure_ascii=False, indent=1)) # 3) Weekly planner await pg.click('#tabs button[data-view="weekly"]') await pg.wait_for_timeout(1800) wk = await pg.evaluate("""() => { const v=document.getElementById('view-weekly'); const txt=v.innerText; const hit=tasks.filter(x=>x.cat==='routine').filter(x=>txt.includes(x.title)).map(x=>x.title); return {visible: hit.length, of: tasks.filter(x=>x.cat==='routine').length, titles: hit}; }""") print("\nWEEKLY:", json.dumps(wk, ensure_ascii=False, indent=1)) # 4) Dashboard KPI reacts await pg.click('#tabs button[data-view="dashboard"]') await pg.wait_for_timeout(1500) kpi = await pg.evaluate("""() => ({ done: document.getElementById('kpiDone')?.innerText.trim(), hours: document.getElementById('kpiHours')?.innerText.trim() })""") print("\nKPIs:", json.dumps(kpi, ensure_ascii=False)) # 5) list-container (reminders / weekly) any place showing all tasks await pg.screenshot(path="/workspace/parastoo_dashboard/audit/routines_final.png", full_page=True) print("\nJS ERRORS:", errs[:5]) await b.close() asyncio.run(main())