-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.py
More file actions
98 lines (94 loc) · 5.2 KB
/
Copy pathverify.py
File metadata and controls
98 lines (94 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from playwright.sync_api import sync_playwright
def click_top_marker(pg, timeout=6000):
"""Click the first marker that is genuinely the top element at its own centre.
Map pins overlap by nature, so picking `.first` in DOM order can land on one
that is underneath another. This keeps Playwright's real hit-testing (so a
genuine overlay bug would still fail) while tolerating normal pin overlap.
"""
pg.wait_for_timeout(1200) # let fitBounds settle
idx = pg.evaluate("""() => {
const ms=[...document.querySelectorAll('.leaflet-marker-icon')];
for (let i=0;i<ms.length;i++){
const r=ms[i].getBoundingClientRect();
const el=document.elementFromPoint(r.left+r.width/2, r.top+r.height/2);
if (el && (el===ms[i] || ms[i].contains(el))) return i;
}
return -1;
}""")
if idx < 0: return False
pg.locator(".leaflet-marker-icon").nth(idx).click(timeout=timeout)
return True
import sys, json
errs, reqfail, console = [], [], []
with sync_playwright() as p:
b = p.chromium.launch()
pg = b.new_page(viewport={"width":1440,"height":950}, device_scale_factor=2)
pg.on("console", lambda m: console.append((m.type, m.text[:200])))
pg.on("pageerror", lambda e: errs.append(str(e)[:300]))
pg.on("requestfailed", lambda r: reqfail.append(r.url[:120]+" :: "+str(r.failure)[:80]))
pg.goto("http://127.0.0.1:8765/van.html", wait_until="load", timeout=60000)
pg.wait_for_timeout(6000)
res = pg.evaluate("""() => ({
days: document.querySelectorAll('.day-btn').length,
chips: document.querySelectorAll('#chips .chip').length,
itinDays: document.querySelectorAll('#itinerary .day').length,
stops: document.querySelectorAll('.stoplist li').length,
stayCards: document.querySelectorAll('#stayGrid .card').length,
campRows: document.querySelectorAll('#campBody tr').length,
hikeRows: document.querySelectorAll('#hikeBody tr').length,
beachCards: document.querySelectorAll('#beachGrid .card').length,
pins: document.querySelectorAll('.leaflet-marker-icon').length,
paths: document.querySelectorAll('#map path').length,
tiles: document.querySelectorAll('.leaflet-tile-loaded').length,
statKm: (document.getElementById('sKm')||{}).textContent,
statHikes: (document.getElementById('sHikes')||{}).textContent,
leaflet: typeof window.L,
docH: document.body.scrollHeight
})""")
print(json.dumps(res, indent=1))
pg.screenshot(path="shots/01-hero.png", clip={"x":0,"y":0,"width":1440,"height":950})
pg.evaluate("document.querySelector('#map-section').scrollIntoView()")
pg.wait_for_timeout(3500)
pg.screenshot(path="shots/02-map-all.png")
# click day 7
pg.click(".day-btn[data-day='7']"); pg.wait_for_timeout(2800)
pg.screenshot(path="shots/03-map-day7.png")
d7 = pg.evaluate("() => document.querySelectorAll('.leaflet-marker-icon').length")
print("pins visible after selecting day 7:", d7)
# open a popup
pg.evaluate("document.querySelector('#mapReset').click()"); pg.wait_for_timeout(1500)
pg.click(".day-btn[data-day='10']"); pg.wait_for_timeout(2500)
if click_top_marker(pg):
pg.wait_for_timeout(1200)
pg.screenshot(path="shots/04-popup.png")
print("popup open:", pg.evaluate("()=>!!document.querySelector('.leaflet-popup')"))
# chip toggle
pg.evaluate("document.querySelector('#mapReset').click()"); pg.wait_for_timeout(1200)
before = pg.evaluate("()=>document.querySelectorAll('.leaflet-marker-icon').length")
pg.query_selector_all("#chips .chip")[0].click(); pg.wait_for_timeout(800)
after = pg.evaluate("()=>document.querySelectorAll('.leaflet-marker-icon').length")
print("chip filter pins:", before, "->", after)
# itinerary + other sections
pg.evaluate("document.querySelector('#itinerary-section').scrollIntoView()"); pg.wait_for_timeout(900)
pg.screenshot(path="shots/05-itinerary.png")
pg.evaluate("document.querySelector('#stay').scrollIntoView()"); pg.wait_for_timeout(900)
pg.screenshot(path="shots/06-hotels.png")
pg.evaluate("document.querySelector('#camping').scrollIntoView()"); pg.wait_for_timeout(900)
pg.screenshot(path="shots/07-camping.png")
pg.evaluate("document.querySelector('#hikes').scrollIntoView()"); pg.wait_for_timeout(900)
pg.screenshot(path="shots/08-hikes.png")
pg.evaluate("document.querySelector('#logistics').scrollIntoView()"); pg.wait_for_timeout(900)
pg.screenshot(path="shots/09-logistics.png")
pg.evaluate("document.querySelector('#money').scrollIntoView()"); pg.wait_for_timeout(900)
pg.screenshot(path="shots/10-budget.png")
# mobile
m = b.new_page(viewport={"width":390,"height":844}, device_scale_factor=2, is_mobile=True)
m.goto("http://127.0.0.1:8765/van.html", wait_until="load"); m.wait_for_timeout(5000)
m.screenshot(path="shots/11-mobile.png")
m.evaluate("document.querySelector('#map-section').scrollIntoView()"); m.wait_for_timeout(2500)
m.screenshot(path="shots/12-mobile-map.png")
b.close()
print("\nPAGE ERRORS:", errs or "none")
print("FAILED REQUESTS:", reqfail or "none")
bad=[c for c in console if c[0] in ("error","warning")]
print("CONSOLE err/warn:", bad or "none")