Skip to content

Commit 7ef8317

Browse files
AVC: Try clicking as UiObject w/ UIAH, then fallback to coords
If UiAutomatorHelper is being used, and a View is clicked, find the UiObject first, and click it; but fallback to co-ords if this fails.
1 parent 2298195 commit 7ef8317

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/com/dtmilano/android/viewclient.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,16 @@ def touch(self, eventType=adbclient.DOWN_AND_UP, deltaX=0, deltaY=0):
928928
self.device.touch(x+10, y+10, eventType=adbclient.UP)
929929
else:
930930
if self.uiAutomatorHelper:
931-
# FIXME: this could be also clicking the View by OID if findObject() were used to find the Views
932-
self.uiAutomatorHelper.click(x=x, y=y)
931+
try:
932+
oid = self.uiAutomatorHelper.findObject(self.getId())
933+
if DEBUG_UI_AUTOMATOR_HELPER:
934+
print >> sys.stderr, "oid=", oid
935+
print >> sys.stderr, "ignoring click delta to click View as UiObject"
936+
oid.click();
937+
except RuntimeError as e:
938+
print >> sys.stderr, e.message
939+
print >> sys.stderr, "UiObject click failed, using co-ordinates"
940+
self.uiAutomatorHelper.click(x, y)
933941
else:
934942
self.device.touch(x, y, eventType=eventType)
935943

0 commit comments

Comments
 (0)