55 lines
No EOL
2.7 KiB
Python
55 lines
No EOL
2.7 KiB
Python
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": 1600, "height": 1100}, device_scale_factor=1.5)
|
||
errs = []
|
||
pg.on("pageerror", lambda e: errs.append(f"PAGEERR {e}"))
|
||
pg.on("console", lambda m: errs.append(f"CONSOLE {m.text}") if m.type == "error" else None)
|
||
|
||
await pg.goto("https://parastoo.zebellkhan.com/", wait_until="networkidle", timeout=90000)
|
||
await pg.wait_for_timeout(4000)
|
||
|
||
# TEAM TAB
|
||
await pg.click('nav.tabs button[data-view="team"]')
|
||
await pg.wait_for_timeout(6000)
|
||
team = await pg.evaluate("""() => ({
|
||
meta: document.getElementById('teamMeta')?.innerText,
|
||
cards: document.querySelectorAll('#teamCards .card').length,
|
||
detail: document.querySelectorAll('#teamDetail .card').length,
|
||
verdict: document.getElementById('teamVerdict')?.innerText.slice(0, 220),
|
||
textLen: document.getElementById('view-team').innerText.length
|
||
})""")
|
||
|
||
# REMINDERS TAB
|
||
await pg.click('nav.tabs button[data-view="remind"]')
|
||
await pg.wait_for_timeout(4000)
|
||
remind = await pg.evaluate("""() => ({
|
||
meta: document.getElementById('remindMeta')?.innerText,
|
||
platformCards: document.querySelectorAll('#remindCalendar .card').length,
|
||
calDays: document.querySelectorAll('#calendarDays .card').length,
|
||
dailyItems: document.querySelectorAll('#dailyTasks .task-row').length,
|
||
customReminders: document.querySelectorAll('#customReminders .task-row').length,
|
||
textLen: document.getElementById('view-remind').innerText.length,
|
||
overflow: document.documentElement.scrollWidth - document.documentElement.clientWidth
|
||
})""")
|
||
|
||
# ADD a personal reminder via UI
|
||
await pg.fill('#remTitle', 'تست یادآور — پیگیری بلاگر')
|
||
await pg.select_option('#remFreq', 'daily')
|
||
await pg.click('button:has-text("➕ افزودن یادآور")')
|
||
await pg.wait_for_timeout(1200)
|
||
remind["afterAdd"] = await pg.evaluate("() => document.querySelectorAll('#customReminders .task-row').length")
|
||
|
||
# screenshot
|
||
await pg.screenshot(path="/workspace/parastoo_dashboard/audit/team_tab.png", full_page=True)
|
||
await pg.click('nav.tabs button[data-view="remind"]')
|
||
await pg.wait_for_timeout(2000)
|
||
await pg.screenshot(path="/workspace/parastoo_dashboard/audit/remind_tab.png", full_page=True)
|
||
|
||
print(json.dumps({"team": team, "remind": remind, "errors": errs[:6]}, ensure_ascii=False, indent=2))
|
||
await b.close()
|
||
|
||
asyncio.run(main()) |