MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / _resolve_selector

Function _resolve_selector

src/sandbox_vm/tools/app_control/browser.py:599–622  ·  view source on GitHub ↗
(
    page, state: _SessionState, *, target_id: str
)

Source from the content-addressed store, hash-verified

597
598
599async def _resolve_selector(
600 page, state: _SessionState, *, target_id: str
601) -> Tuple[Optional[str], Optional[Dict[str, Any]]]:
602 rec = next((o for o in state.internal if o["target_id"] == target_id), None)
603 if rec is None:
604 return None, None
605 for sel in rec.get("selectors", []):
606 try:
607 if await page.query_selector(sel):
608 return sel, rec
609 except Exception:
610 continue
611 ps = rec.get("pathSig")
612 if ps:
613 try:
614 if await page.query_selector(ps):
615 return ps, rec
616 except Exception:
617 pass
618
619 new_sel = await _reacquire_selector(page, rec)
620 if new_sel:
621 return new_sel, rec
622 return None, rec
623
624
625async def _type_or_click(

Callers 1

_runFunction · 0.85

Calls 3

nextFunction · 0.85
_reacquire_selectorFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected