import sys, time
from pathlib import Path
sys.path.append(str(Path("05_Production_Pipeline").resolve()))
from invisible_playwright import InvisiblePlaywright
from muse_invpw_driver import DEFAULT_PROFILE

def check_artifacts():
    with InvisiblePlaywright(profile_dir=DEFAULT_PROFILE, headless=True) as ctx:
        page = ctx.pages[0] if ctx.pages else ctx.new_page()
        page.goto("https://muse.ai/library/artifacts", wait_until="domcontentloaded", timeout=30000)
        time.sleep(5)
        
        page.screenshot(path="04_Assets/library_artifacts_home.png")
        print("Saved screenshot to 04_Assets/library_artifacts_home.png")
        print("Page URL:", page.url)
        
        # Check text
        body_text = page.locator('body').inner_text()
        print("Body text excerpt:")
        for line in body_text.splitlines()[:30]:
            if line.strip():
                print("  ", line.strip())

if __name__ == '__main__':
    check_artifacts()
