"""Load /testimonials and report what's actually visible.""" from playwright.sync_api import sync_playwright import sys, io sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') BASE = "http://127.0.0.1:5180" def run(): with sync_playwright() as p: browser = p.chromium.launch() for label, ctx_opts in [ ("desktop", {"viewport": {"width": 1280, "height": 900}}), ("mobile", {"viewport": {"width": 390, "height": 844}, "is_mobile": True, "has_touch": True, "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1"}), ]: print(f"\n=== {label} ===") ctx = browser.new_context(**ctx_opts) page = ctx.new_page() logs = [] page.on("console", lambda m, L=logs: L.append(f"[{m.type}] {m.text}")) page.on("pageerror", lambda e, L=logs: L.append(f"[pageerror] {e}")) page.goto(BASE + "/testimonials", wait_until="networkidle", timeout=30000) page.wait_for_timeout(600) section = page.locator(".testimonials-page-grid-section") print(f" section count: {section.count()}") classes = section.first.get_attribute("class") if section.count() else None print(f" section classes: {classes!r}") cards = page.locator(".testimonials-page-card") print(f" cards count: {cards.count()}") if cards.count(): first = cards.first computed = first.evaluate("el => { const cs = getComputedStyle(el); return { opacity: cs.opacity, transform: cs.transform, display: cs.display, visibility: cs.visibility }; }") print(f" first card computed: {computed}") bb = first.bounding_box() print(f" first card bbox: {bb}") txt = first.inner_text() print(f" first card text: {txt[:200]!r}") # Scroll into view and re-check if section.count(): section.first.scroll_into_view_if_needed() page.wait_for_timeout(800) classes2 = section.first.get_attribute("class") print(f" section classes after scroll: {classes2!r}") if cards.count(): op2 = cards.first.evaluate("el => getComputedStyle(el).opacity") print(f" first card opacity after scroll: {op2}") page.screenshot(path=f"scripts/testimonials-{label}.png", full_page=True) print(f" screenshot: scripts/testimonials-{label}.png") if logs: print(" console:") for l in logs[-15:]: print(f" {l}") ctx.close() browser.close() run()