"""Capture the lean Scout POC screens.""" import asyncio from browser_use import BrowserSession from browser_config import make_profile URL = "http://localhost:8099/" CLICK = """(()=>{const t=%r.toLowerCase();const el=[...document.querySelectorAll('button')] .find(e=>(e.textContent||'').trim().toLowerCase().includes(t));if(el){el.click();return el.textContent.trim()}return null})()""" async def click(s, t): cdp = await s.get_or_create_cdp_session() r = await cdp.cdp_client.send.Runtime.evaluate( params={"expression": CLICK % t, "returnByValue": True}, session_id=cdp.session_id) return r.get("result", {}).get("value") async def shot(s, p): await s.take_screenshot(path=p, full_page=True); print("shot", p) async def main(): s = BrowserSession(browser_profile=make_profile(headless=True, persist=False)) await s.start() try: await s._cdp_set_viewport(width=720, height=1024) except Exception: pass await s.navigate_to(URL); await asyncio.sleep(3.5) await shot(s, "/tmp/scout_1_config.png") print("find ->", await click(s, "Find my matches")); await asyncio.sleep(6.5) await shot(s, "/tmp/scout_2_deck.png") print("apply ->", await click(s, "Apply")); await asyncio.sleep(1.5) await shot(s, "/tmp/scout_3_applied.png") await s.kill() asyncio.run(main())