dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.62k stars 345 forks source link

Example of using Pinch #323

Closed gonzalesMK closed 8 months ago

gonzalesMK commented 9 months ago

Hey folks, would you mind sharing an example on how to use pinch ?

I tried this piece of code without success:

oid=helper.ui_device.find_object(pkg="my.game.package").oid
helper.ui_object.pinch_in(oid=oid, percentage=10,steps=100)

But I got this error:


ERROR: java.lang.ClassCastException: androidx.test.uiautomator.UiObject2 cannot be cast to androidx.test.uiautomator.UiObject
`` `
dtmilano commented 9 months ago

Try

oid=helper.ui_device.find_object(ui_selector="package@my.game.package").oid
helper.ui_object.pinch_in(oid=oid, percentage=10, steps=100)

because depending on the selector find_object either returns UiObject or UiObject2.

dtmilano commented 9 months ago

Check https://mrin9.github.io/OpenAPI-Viewer/#/load/https%3A%2F%2Fraw.githubusercontent.com%2Fdtmilano%2FCulebraTester2-public%2Fmaster%2Fopenapi.yaml for more details.

dtmilano commented 9 months ago

avc-pinch-out-2

This is an example of pinch out.