61 lines
No EOL
2.9 KiB
Python
61 lines
No EOL
2.9 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": 1500, "height": 1000})
|
||
errs = []
|
||
pg.on("pageerror", lambda e: errs.append(f"PAGEERR {e}"))
|
||
pg.on("console", lambda m: errs.append(f"C {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(2500)
|
||
await pg.click('#tabs button[data-view="calendar"]')
|
||
await pg.wait_for_timeout(2500)
|
||
|
||
# 1) decimal separator check across the whole calendar view
|
||
dec = await pg.evaluate("""() => {
|
||
const v = document.getElementById('view-calendar');
|
||
const t = v.innerText;
|
||
return {
|
||
latinDots: (t.match(/[۰-۹]\\.[۰-۹]/g) || []),
|
||
persianDots: (t.match(/[۰-۹]\\u066B[۰-۹]/g) || []),
|
||
latinDigits: (t.match(/[0-9]/g) || []).length
|
||
};
|
||
}""")
|
||
|
||
# 2) click navigation buttons — do prev/next/today actually work?
|
||
nav = await pg.evaluate("""() => {
|
||
const before = document.getElementById('calRange')?.innerText.trim();
|
||
return {before};
|
||
}""")
|
||
await pg.click('#view-calendar button:has-text("هفته قبل")')
|
||
await pg.wait_for_timeout(1400)
|
||
prev = await pg.evaluate("() => document.getElementById('calRange')?.innerText.trim()")
|
||
await pg.click('#view-calendar button:has-text("هفته بعد")')
|
||
await pg.wait_for_timeout(1400)
|
||
nxt = await pg.evaluate("() => document.getElementById('calRange')?.innerText.trim()")
|
||
await pg.click('#view-calendar button:has-text("امروز")')
|
||
await pg.wait_for_timeout(1400)
|
||
today = await pg.evaluate("() => document.getElementById('calRange')?.innerText.trim()")
|
||
|
||
# 3) click a day cell — does the detail panel update?
|
||
day = await pg.evaluate("""() => {
|
||
const cells = [...document.querySelectorAll('#calGrid .day')];
|
||
const target = cells[1];
|
||
const before = document.getElementById('dayDetailTitle')?.innerText.trim();
|
||
target.click();
|
||
return {before, clickedNum: target.querySelector('.day-num')?.innerText.trim()};
|
||
}""")
|
||
await pg.wait_for_timeout(1300)
|
||
detail = await pg.evaluate("""() => ({
|
||
after: document.getElementById('dayDetailTitle')?.innerText.trim(),
|
||
rows: document.querySelectorAll('#dayDetail .task-row').length
|
||
})""")
|
||
|
||
print(json.dumps({"decimals": dec, "nav": {"initial": nav["before"], "prev": prev,
|
||
"next": nxt, "today": today}, "dayClick": {**day, **detail},
|
||
"errors": errs[:5]}, ensure_ascii=False, indent=2))
|
||
await b.close()
|
||
|
||
asyncio.run(main()) |