MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / longTouch

Method longTouch

src/com/dtmilano/android/viewclient.py:1070–1101  ·  view source on GitHub ↗

Long touches this C{View} @param duration: duration in ms

(self, duration=2000)

Source from the content-addressed store, hash-verified

1068 return None
1069
1070 def longTouch(self, duration=2000):
1071 """
1072 Long touches this C{View}
1073
1074 @param duration: duration in ms
1075 """
1076
1077 x, y = self.getCenter()
1078
1079 if self.uiAutomatorHelper:
1080 selector = self.obtain_selector()
1081 if DEBUG_UI_AUTOMATOR_HELPER:
1082 print('using selector="%s"' % selector, file=sys.stderr)
1083 if selector:
1084 try:
1085 object_ref = self.uiAutomatorHelper.ui_device.find_object(body=selector)
1086 if DEBUG_UI_AUTOMATOR_HELPER:
1087 print("♦️ object_ref=%s" % object_ref, file=sys.stderr)
1088 self.uiAutomatorHelper.ui_object2.long_click(oid=object_ref.oid)
1089 except RuntimeError as e:
1090 print(e, file=sys.stderr)
1091 print("UiObject2 click failed, falling back to coordinates", file=sys.stderr)
1092 self.uiAutomatorHelper.ui_device.click(x=x, y=y)
1093 else:
1094 # FIXME:
1095 # The View has no CD, TEXT or ID so we cannot use it in a selector to findObject()
1096 # We should try content description, text, and perhaps other properties before surrendering.
1097 # For now, tet's fall back to click(x, y)
1098 self.uiAutomatorHelper.ui_device.click(x=x, y=y)
1099 else:
1100 # FIXME: get orientation
1101 self.device.longTouch(x, y, duration, orientation=-1)
1102
1103 def allPossibleNamesWithColon(self, name):
1104 l = []

Callers 3

longTouchPointMethod · 0.45
longTouchViewMethod · 0.45
longTouchMethod · 0.45

Calls 5

getCenterMethod · 0.95
obtain_selectorMethod · 0.95
long_clickMethod · 0.80
find_objectMethod · 0.45
clickMethod · 0.45

Tested by

no test coverage detected