Skip to content

Selected element is not reported if the selected element is not part of the a11y snapshot #586

Closed

Description

@natorion

Description of the bug

Selected elements are ommited if they are not relevant for interacting with the page.

Reproduction

Repro:

1.) Open page that has a lot of divs and a few controls
2.) Select one of the divs in DevTools
3.) Reference in your prompt the selected element
4.) take_snapshot does not include the div

Expectation

a selected element should always be added to take_snapshot - no matter what type it is.

MCP configuration

No response

Chrome DevTools MCP version

0.10

Chrome version

No response

Coding agent version

No response

Model version

No response

Chat log

No response

Node version

No response

Operating system

None

Extra checklist

  • I want to provide a PR to fix this bug

Activity

  1. added theissue type on Nov 20, 2025
  2. changed the issue type fromtoon Nov 20, 2025
  3. OrKoN commented on Nov 20, 2025

    @OrKoN
    Collaborator

    Have you tried requesting verbose snapshots?

  4. assigned and unassigned on Nov 20, 2025
  5. removed theissue type on Nov 20, 2025
  6. added theissue type on Nov 20, 2025
  7. natorion commented on Nov 20, 2025

    @natorion
    ContributorAuthor

    Have you tried requesting verbose snapshots?

    It works with that. A human would not know that, and an AI agent does not know either. So two options:

    • Add the selected element always
    • returns a verbose snapshot always when an element is selected (token intensive)
  8. assigned and unassigned on Nov 20, 2025
  9. OrKoN commented on Nov 20, 2025

    @OrKoN
    Collaborator

    Add the selected element always

    this would not be doable right now since filtering is on the puppeteer side.

    returns a verbose snapshot always when an element is selected (token intensive)

    This can be done.

    Thanks for providing the feedback.

  10. natorion commented on Nov 20, 2025

    @natorion
    ContributorAuthor

    Can we filter it down to the non-verbose screenshot afterwards before passing it on to the LLM?

  11. OrKoN commented on Nov 20, 2025

    @OrKoN
    Collaborator

    Can we filter it down to the non-verbose screenshot afterwards before passing it on to the LLM?

    Code architecture would not allow to re-use the exact same code right now. Definitely possible but a larger change. Do you prefer this option? The other option is possible right now (next days).

    Another option could be to use verbose by default? In general, for styling debugging we need to rework the snapshots to be a mix of DOM and a11y but that requires some thinking.

  12. natorion commented on Nov 20, 2025

    @natorion
    ContributorAuthor

    I worry that makign verbose will just burn more tokens. The verbose snapshot is big compared to the normal one. Alternatively: How about mentioning in the tool description of take_snapshot that verbose=true should be used if the selected element is not showing up? This way an AI agent (or human) is able to figure out the problem without increasing token cost per operation massively.

  13. OrKoN commented on Nov 20, 2025

    @OrKoN
    Collaborator

    How about mentioning in the tool description of take_snapshot that verbose=true should be used if the selected element is not showing up?

    This is an option but I am not sure how well LLMs would be able to follow it. As a short-term solution it would be fine. I could add a line to the response output like There is a selected element in the Elements panel call take_snapshot(verbose=true) to see. It would only show up if the snapshot is not already verbose and there is actually an element selected.

  14. natorion commented on Nov 20, 2025

    @natorion
    ContributorAuthor

    How about mentioning in the tool description of take_snapshot that verbose=true should be used if the selected element is not showing up?

    This is an option but I am not sure how well LLMs would be able to follow it. As a short-term solution it would be fine. I could add a line to the response output like There is a selected element in the Elements panel call take_snapshot(verbose=true) to see. It would only show up if the snapshot is not already verbose and there is actually an element selected.

    I like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions