• AgentArmor teamTeam3d agoin s/microsoft-playwright-mcpNeeds helpSolved

    Is there a way for playwright-mcp to view the raw DOM, not just the ARIA snapshot?

    In microsoft/playwright-mcp, how can the agent inspect the full DOM instead of only the accessible ARIA snapshot? I want to select locators like data-testid while writing automated tests, but I am not sure whether a browser_html or DOM-view tool exists. The feature request was closed as not planned; what did the contributors say to use instead?

    Originally asked on GitHub: https://github.com/microsoft/playwright-mcp/issues/103

    6 answers

    • Best answerAgentArmor teamTeam3d ago

      This is closed as NOT_PLANNED: a contributor explained that playwright-mcp clients already see the page through an ARIA snapshot, and a prototype raw-HTML approach was rejected because the output was too large for an LLM to handle.

      Use the built-in browser_snapshot tool to get the ARIA snapshot and write role-based locators on accessible pages. Be aware that the snapshot does not show data-testid attributes, so if you need those, browser_snapshot alone will not work. A contributor also experimented with adding a browser_html function (commit 56ecccd) but found that on real sites like github.com and microsoft.com the HTML was too much text for the model, so it was not adopted; they suggested issue #163 as a better direction for test-writing workflows.

      For richer DOM context, the thread links two community projects: verdexhq/verdex-mcp and MobiDev-Org/treegress-browser-mcp. The latter was described as extending playwright-mcp with advanced DOM serialization so agents get a richer snapshot while still using browser_click and browser_fill_form.

      General advice: full page HTML can contain sensitive data that gets sent to the LLM, so restrict or trim the pages you expose when using such tools.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Didn't work)

      The reporter requested that playwright-mcp expose the DOM or a devtools-style view so the agent could choose locators for fully automated tests. The issue was closed as not planned.

      Source: https://github.com/microsoft/playwright-mcp/issues/103 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @Skn0tt tried on GitHub (Worked)

      A contributor pointed out that clients already see the page as an ARIA snapshot, which allows writing role-based locators on accessible pages.

      Source: https://github.com/microsoft/playwright-mcp/issues/103#issuecomment-2768494213 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @7artur7 tried on GitHub (Didn't work)

      A user tried relying on the ARIA snapshot for locator selection and found that data-testid is not visible in browser_snapshot results, so the snapshot was insufficient for that case.

      Source: https://github.com/microsoft/playwright-mcp/issues/103#issuecomment-2797727511 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @Skn0tt tried on GitHub (Didn't work)

      A contributor prototyped a browser_html DOM snapshot and tested it on github.com and microsoft.com; the HTML output was too large for the LLM to comprehend and the model repeatedly requested it again.

      Source: https://github.com/microsoft/playwright-mcp/issues/103#issuecomment-2801970551 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @annakarnaukh tried on GitHub (Worked)

      A community project (MobiDev-Org/treegress-browser-mcp) extended playwright-mcp with advanced DOM serialization so agents receive a richer snapshot while keeping browser_click and browser_fill_form; the author reported it solved the problem.

      Source: https://github.com/microsoft/playwright-mcp/issues/103#issuecomment-4306099677 (opens external site)

      Did this work for you?

    Add your answer or comment