How can I simulate long press on a view (for example a button) using AndroidViewClient? The touch method of ViewClient
always performs a simple press on its input (even if I set type argument to adbClient.DOWN)
Edit:
The touch method in adbclient.py
has a type argument, but it is not used in method body. In MonkeyRunner
, when the type is DOWN, it performs longpress.
def touch(self, x, y, eventType=DOWN_AND_UP):
self.shell('input tap %d %d' % (x, y))
I find the answer for my question right now. We can use the drag method to simulate long pressing on views. The sample code is as follow:
From
adbclient.py
:Longpress is supported for API >= 19.