84 lines
3.1 KiB
Python
84 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Deep DOM Diagnostic v2"""
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
BASE_URL = "http://localhost:3001"
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True)
|
|
page = browser.new_page(viewport={"width": 1280, "height": 900})
|
|
|
|
console_logs = []
|
|
page.on("console", lambda msg: console_logs.append(f"{msg.type}: {msg.text[:150]}"))
|
|
|
|
# Navigate directly to CTA area
|
|
page.goto(BASE_URL + "/#cta")
|
|
page.wait_for_load_state("networkidle")
|
|
page.wait_for_timeout(2000) # Extra wait for dynamic imports
|
|
|
|
print("=== CTA SECTION DEEP PROBE ===")
|
|
cta = page.locator("#cta")
|
|
print(f"#cta exists: {cta.count() > 0}")
|
|
if cta.count() > 0:
|
|
html = cta.first.inner_html()
|
|
print(f"#cta innerHTML length: {len(html)}")
|
|
print(f"#cta innerHTML (first 500 chars): {html[:500]}")
|
|
|
|
# Check for anchor tags
|
|
anchors = cta.locator("a")
|
|
print(f"\n#cta <a> tags: {anchors.count()}")
|
|
for i in range(anchors.count()):
|
|
a = anchors.nth(i)
|
|
txt = a.inner_text().strip()
|
|
href = a.get_attribute("href") or ""
|
|
cls = a.get_attribute("class") or ""
|
|
print(f" a[{i}]: text='{txt}' href={href} class={cls[:80]}")
|
|
|
|
# Check all clickable elements
|
|
clickables = cta.locator("a, button, [role='button'], [role='link']")
|
|
print(f"\n#cta all clickables: {clickables.count()}")
|
|
|
|
print("\n=== WHY-US DEEP PROBE ===")
|
|
whyus = page.locator("#why-us")
|
|
print(f"#why-us exists: {whyus.count() > 0}")
|
|
if whyus.count() > 0:
|
|
anchors = whyus.locator("a")
|
|
print(f"#why-us <a> tags: {anchors.count()}")
|
|
for i in range(anchors.count()):
|
|
a = anchors.nth(i)
|
|
txt = a.inner_text().strip()
|
|
href = a.get_attribute("href") or ""
|
|
print(f" a[{i}]: text='{txt}' href={href}")
|
|
|
|
print("\n=== HEADER CONSULT DEEP PROBE ===")
|
|
header = page.locator("header")
|
|
header_anchors = header.locator("a")
|
|
print(f"header <a> tags: {header_anchors.count()}")
|
|
for i in range(header_anchors.count()):
|
|
a = header_anchors.nth(i)
|
|
txt = a.inner_text().strip()[:30]
|
|
href = a.get_attribute("href") or ""
|
|
aria = a.get_attribute("aria-label") or ""
|
|
if '咨询' in txt or '咨询' in aria or 'contact' in href:
|
|
print(f" CONSULT a[{i}]: text='{txt}' href={href} aria={aria}")
|
|
|
|
header_buttons = header.locator("button")
|
|
print(f"header <button> tags: {header_buttons.count()}")
|
|
for i in range(header_buttons.count()):
|
|
b = header_buttons.nth(i)
|
|
txt = b.inner_text().strip()[:30]
|
|
print(f" btn[{i}]: text='{txt}'")
|
|
|
|
print("\n=== BODY TEXT CHECK ===")
|
|
body_text = page.locator("body").inner_text()
|
|
for kw in ["预约免费咨询", "了解核心团队", "咨询"]:
|
|
idx = body_text.find(kw)
|
|
print(f" '{kw}': found at index {idx}" if idx >= 0 else f" '{kw}': NOT FOUND")
|
|
|
|
print("\n=== CONSOLE ERRORS ===")
|
|
errors = [l for l in console_logs if l.startswith("error:")]
|
|
for e in errors[:10]:
|
|
print(f" {e}")
|
|
|
|
browser.close()
|