피드로 돌아가기
My agent could see the dropdown. It just couldn't pick anything.
Dev.toDev.to
Frontend

Deep-DOM 탐색 통합으로 Shadow Root 및 Iframe 내 요소 제어 결함 해결

My agent could see the dropdown. It just couldn't pick anything.

אחיה כהן2026년 5월 24일5intermediate

Context

Salesforce Lightning과 같이 Iframe과 다중 Shadow Root가 중첩된 복잡한 DOM 구조에서 표준 document.querySelector의 탐색 한계 발생. 특정 도구(safari_click)는 Deep-DOM 탐색 로직을 보유했으나 safari_select_option은 Top-frame 기반의 단일 경로 탐색으로 인해 요소 접근 불가 현상 노출.

Technical Solution

  • Element-resolution 경로의 단일화 및 추상화 레이어 도입
  • mcpFindRef를 통한 Accessibility Snapshot 기반의 Ref-to-Element 매핑 로직 적용
  • mcpQuerySelectorDeep를 활용하여 모든 Same-origin Iframe 및 Shadow Root를 재귀적으로 탐색하는 Deep-walk 전략 수립
  • Top-frame 쿼리를 우선 수행한 후 실패 시 Deep-walker로 Fallback하는 최적화 경로 설계
  • safari_select_option 도구에 safari_click과 동일한 요소 식별 인터페이스를 통합하여 일관성 확보

1. UI 자동화 도구 내 모든 요소 접근 경로가 동일한 탐색 알고리즘을 공유하는지 검토

2. Shadow DOM 및 Iframe 중첩 구조에 대비한 재귀적 탐색 로직(Deep-walker) 구현 여부 확인

3. Snapshot 기반 Ref와 CSS Selector 기반 쿼리 간의 결과 일관성 검증

원문 읽기