Skip to content

Commit

Permalink
Fix native tap with instance
Browse files Browse the repository at this point in the history
  • Loading branch information
pdenert committed Jan 21, 2025
1 parent a2bc620 commit 22d48fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/patrol/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

- Fix `$.native.tap()` not working with `Selector` having `instance` set.

## 3.14.0

- Remove `exception` from `StepEntry`. When it was too long, it caused crash because of badly formed JSON. (#2481)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,24 @@ class AutomatorServer(private val automation: Automator) : NativeAutomatorServer

override fun tap(request: TapRequest) {
if (request.selector != null) {
/// Remove instance before creating bySelector
var selector2 = request.selector.copy(instance = null)
val bySelector = selector2.toBySelector()

automation.tap(
uiSelector = request.selector.toUiSelector(),
bySelector = request.selector.toBySelector(),
bySelector = bySelector,
index = request.selector.instance?.toInt() ?: 0,
timeout = request.timeoutMillis
)
} else if (request.androidSelector != null) {
/// Remove instance before creating bySelector
var androidSelector2 = request.androidSelector.copy(instance = null)
val bySelector = androidSelector2.toBySelector()

automation.tap(
uiSelector = request.androidSelector.toUiSelector(),
bySelector = request.androidSelector.toBySelector(),
bySelector = bySelector,
index = request.androidSelector.instance?.toInt() ?: 0,
timeout = request.timeoutMillis
)
Expand Down

0 comments on commit 22d48fa

Please sign in to comment.