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(4)
    print("URL:", page.url)
    print("Title:", page.title())
    
    file_inputs = page.locator('input[type="file"]').count()
    textareas = page.locator('textarea, [contenteditable="true"], [role="textbox"]').count()
    print(f"File inputs: {file_inputs}")
    print(f"Textareas: {textareas}")
    
    # Check chat box locator details
    chat_box = page.locator('textarea, [placeholder*="Nhắn tin"], [placeholder*="Message"], [role="textbox"]').first
    if chat_box.count() > 0:
        print(f"Chat box tag: {chat_box.evaluate('el => el.tagName')} | placeholder: {chat_box.get_attribute('placeholder')}")
        
    buttons = page.locator("button").all_inner_texts()
    print("Sample buttons:", [b.strip() for b in buttons if b.strip()][:15])
