[Feature]: Official APIs to resolve/map ephemeral aria-refs to stable locators for LLM automation
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- playwright, python
- Domaine
- ai, devtools, testing-qa
Piste de recherche
The issue requests new APIs to map ephemeral aria-refs to stable locators for LLM automation. Start by examining the existing aria_snapshot(mode="ai") implementation and the private codegen utilities. Look for internal methods like generateLocator or exposeConsoleApi. The goal is to design a public API that returns a Locator object or a structured selector bundle from a given aria-ref.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
🚀 Feature Request
With the rapid evolution of LLM-driven browser automation (especially leveraging Playwright's excellent aria_snapshot(mode="ai")), there is a growing need to bridge the gap between ephemeral AI session references (aria-ref=e5) and persistent, deterministic locators.
Currently, LLM agents perceive the page through temporary aria-ref identifiers. However, to "compile" these exploratory runs into reusable production scripts, developers must map these temporary refs to stable, best-practice locators (e.g., get_by_role, get_by_text).
While Playwright's internal codegen engine is powerful for this, it is currently locked behind private APIs. More importantly, simply generating a code string is often not enough; developers need a native, structured way to resolve an aria-ref into a stable Locator object or a "locator bundle" (role, name, css, xpath) to maintain this mapping throughout the automation pipeline.
Example
I would love to see official APIs that allow developers to programmatically resolve and map aria-refs to stable locators. This could take several forms, depending on what fits Playwright's design philosophy best:
- Structured Locator Resolution: Provide a method to resolve an aria-ref directly into a stable Locator object or a structured dictionary of candidate selectors.
- Expose Codegen/Console APIs: Alternatively, officially expose exposeConsoleApi or a dedicated codegen utility so developers can safely access window.playwright.generateLocator without relying on private internals.
Motivation
Right now, the only way to achieve this workflow is by reaching into Playwright's private internals:
# Python example of the current hacky workaround
await context._impl_obj._channel.send("exposeConsoleApi", None, {})
This is undocumented, fragile, and could break in any future release. Furthermore, it forces developers to manually parse and manage the relationship between the temporary ref and the resulting stable locator, without any native support for maintaining this mapping across complex agent workflows.
If this API were officially exposed, it would create a seamless, closed-loop workflow for AI agents:
- AI Perception: Get the page state using snapshot = await page.aria_snapshot(mode="ai")
- LLM Decision: The LLM decides to interact with an element, returning a reference like ref=e5
- Resolution & Mapping...
- Action & Persistence....
Playwright has already taken a huge step forward by introducing aria_snapshot(mode="ai"). Providing a native way to resolve these ephemeral AI refs into stable locators would be the perfect companion feature. It would bridge the gap between ephemeral AI sessions and persistent, deterministic automation, making Playwright the undisputed best framework for building reliable AI web agents.
Thank you for considering this request!
- Langage dominant
- Python
- Étoiles
- 15k
- Forks
- 1.2k
- Merge moyen
- 5 j 12 h
- PR mergées (30 j)
- 10
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoft/playwright-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
microsoft/playwright-python#3208 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
microsoft/playwright-python#3186 ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 1/100
microsoft/playwright-python#3195 ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 72/100
microsoft/playwright-python#3188 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 1/100
microsoft/playwright-python#3172 ·
Toutes les issues de microsoft/playwright-python
Issues similaires
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Ouvertearea: harness bug status: needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Human-Agent-Society/reef#625 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 80/100
learningequality/kolibri#15351 · 2 commentaires ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
Name consistency Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
eellak/triplestore#65 · 1 commentaire ·