import sys, time
sys.stdout.reconfigure(encoding="utf-8")
from pathlib import Path
from invisible_playwright import InvisiblePlaywright

pdir = Path.home() / "AntigravityProfiles" / "phu2234_worker"
with InvisiblePlaywright(profile_dir=pdir, headless=True) as ctx:
    page = ctx.pages[0] if ctx.pages else ctx.new_page()
    page.goto("https://muse.ai", wait_until="domcontentloaded", timeout=25000)
    time.sleep(3)
    chat = page.locator("textarea")
    chat.fill("test")
    time.sleep(1)
    
    btn_elements = page.locator("button, [role='button']").all()
    print("Buttons while text is in chat:")
    for b in btn_elements:
        try:
            txt = b.inner_text().strip()
            aria = b.get_attribute("aria-label") or ""
            if txt or aria:
                print(f"  - button: text='{txt}' | aria='{aria}'")
        except Exception:
            pass
    
    # Clear input
    chat.fill("")
