fix(chrome): emit data-testid so both resolvers name the same element

The V8 host names a web target by data-testid and TapSelector translates that
selector into a CSS attribute match, but the dump carried no such attribute
and no alias could supply one, since an alias only redirects to a key that
already holds the value. tree.Find was therefore always nil for exactly the
selectors examples/folio-web tags with.

Claude-Session: https://claude.ai/code/session_01A5KmftdEJ49A9z5mF5ESrX
This commit is contained in:
pj committed 2026-08-15 13:59:17 +05:30
1 parent 231a74b876
commit 6d03c5788a
3 files changed
+65 -3

No files matched your search

+6
View File
@@ -456,6 +456,12 @@ func (d *Driver) Hierarchy(ctx context.Context) (string, error) {
const text = (el.textContent || '').trim().slice(0, 200);
if (text) attrs.text = text;
if (el.id) attrs['resource-id'] = el.id;
// The V8 host names a target by data-testid (IDENTITY_KEYS in
// pkg/spec/src/web-runtime.ts) and TapSelector translates the selector into
// a CSS attribute match, so a dump without this attribute leaves the goja
// host unable to resolve a target the other two resolve fine.
const testid = el.getAttribute('data-testid');
if (testid) attrs['data-testid'] = testid;
const label = el.getAttribute('aria-label') || el.getAttribute('alt') || el.getAttribute('title') || '';
if (label) attrs['content-desc'] = label;
const tag = (el.tagName || '').toLowerCase();