-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlive_check_positioning.py
More file actions
78 lines (63 loc) · 3.13 KB
/
live_check_positioning.py
File metadata and controls
78 lines (63 loc) · 3.13 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
import time
from playwright.sync_api import sync_playwright
import urllib.request
import ssl
def check_live():
print("Waiting for GitHub Pages to deploy...")
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
max_retries = 30
for i in range(max_retries):
try:
req = urllib.request.Request("https://techstackglobal.github.io/index.html", headers={'User-Agent': 'Mozilla/5.0'}, method='GET')
# Bypass cache
req.add_header('Cache-Control', 'no-cache')
res = urllib.request.urlopen(req, context=ctx)
content = res.read().decode()
if "serious upgrades helping you make" in content:
print("Deployment detected! Proceeding to UI and Console checks.")
break
except Exception as e:
pass
print(f"Waiting for deployment... ({i+1}/{max_retries})")
time.sleep(10)
else:
print("FAIL: Deployment check timed out.")
return
results = {}
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
# 1. Desktop Check
desktop_page = browser.new_page(viewport={'width': 1280, 'height': 800})
console_errors = []
desktop_page.on("console", lambda msg: console_errors.append(msg.text) if msg.type == "error" else None)
try:
r = desktop_page.goto("https://techstackglobal.github.io/", wait_until="networkidle")
results["Desktop render"] = "OK" if r.ok else "FAIL"
# Check for dash characters in intro
intro_text = desktop_page.locator(".homepage-intro p").text_content()
results["No dash characters"] = "OK" if "—" not in intro_text and "-" not in intro_text else f"FAIL ({intro_text})"
# Check console errors
results["No console errors"] = "OK" if len(console_errors) == 0 else f"FAIL ({console_errors})"
except Exception as e:
results["Desktop render"] = f"FAIL ({e})"
# 2. Mobile render and wrapping
mobile_page = browser.new_page(viewport={'width': 375, 'height': 667})
try:
mobile_page.goto("https://techstackglobal.github.io/", wait_until="networkidle")
results["Mobile render"] = "OK"
# Check horizontal overflow
overflow = mobile_page.evaluate("""() => {
return document.documentElement.scrollWidth > window.innerWidth;
}""")
results["No layout shift / Overflow"] = "FAIL (Overflow detected)" if overflow else "OK"
# Ensure text is not squished by checking bounding box of intro
intro_box = mobile_page.locator(".homepage-intro p").bounding_box()
results["No wrapping issues"] = "OK" if intro_box and intro_box["width"] > 300 else f"FAIL (Width: {intro_box['width'] if intro_box else 'None'})"
except Exception as e:
results["Mobile render"] = f"FAIL ({e})"
browser.close()
for k, v in results.items():
print(f"{k}: {v}")
check_live()