feat(chrome): translate legacy string selectors to CSS/XPath

TapSelector now maps id:/desc:/descPrefix:/testTag:/etc. through
TranslateStringSelector. Unknown prefixes pass through to a CSS
attribute selector so a future Maestro key works without a release.
This commit is contained in:
pj committed 2026-04-27 18:39:19 +07:00
1 parent b213f2470b
commit fa0c82fb40
3 files changed
+142 -3

No files matched your search

+10 -3
View File
@@ -126,9 +126,16 @@ func (d *Driver) Tap(_ context.Context, x, y int) error {
}
func (d *Driver) TapSelector(_ context.Context, selector string) error {
return chromedp.Run(d.tabCtx,
chromedp.Click(selector, chromedp.NodeVisible),
)
target, isXPath, err := TranslateStringSelector(selector)
if err != nil {
// Fall back to passing the string straight through; chromedp will
// reject it loudly if it isn't a valid CSS selector.
target = selector
}
if isXPath {
return chromedp.Run(d.tabCtx, chromedp.Click(target, chromedp.NodeVisible, chromedp.BySearch))
}
return chromedp.Run(d.tabCtx, chromedp.Click(target, chromedp.NodeVisible))
}
func (d *Driver) InputText(_ context.Context, text string) error {