Skip to content

Add CSS selector scoping for snapshot and text extraction #49

@justrach

Description

@justrach

Feature

agent-browser supports snapshot -s <sel> and get text <sel> to scope to a CSS selector.

Implementation

  1. Add selector query param to /snapshot and /text
  2. For text: Runtime.evaluate with document.querySelector(sel).innerText
  3. For snapshot: DOM.querySelector to find node, then Accessibility.getPartialAXTree with backendNodeId

Acceptance Criteria

  • /snapshot?tab_id=&selector=.main-content returns only nodes within that element
  • /text?tab_id=&selector=h1 returns only the heading text

Co-authored-by: blackfloofie 265516171+blackfloofie@users.noreply.github.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    blackfloofieCo-author: 265516171+blackfloofie@users.noreply.github.comenhancementNew feature or requestpriority:p2Medium prioritystatus:doneWork item is complete

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions