mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +00:00
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:
1 parent
b213f2470b
commit
fa0c82fb40
3 files changed
+142
-3
No files matched your search
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user