使用AndroidViewClient视图龙preSS [英] Long press on a view using AndroidViewClient

查看:315
本文介绍了使用AndroidViewClient视图龙preSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以模拟长preSS上一个视图(例如按钮)使用 AndroidViewClient ?的触摸方法 ViewClient 总是在其输入(即使我设置的键入的执行一个简单的preSS参数的 adbClient.DOWN

编辑:
adbclient.py 触摸方法具有的键入的说法,但它不是在方法体中。在 MonkeyRunner ,当类型为,它会执行长preSS。

 高清触摸(个体经营,X,Y,EVENTTYPE = DOWN_AND_UP):
    self.shell('输入抽头%D'%(X,Y))


解决方案

我现在找到我的问题的答案。我们可以用拖动的方法来模拟意见长pressing。样品code是如下:

  buttonText ='的ClMe
按钮= vc.findViewWithText(buttonText)
(X,Y)= button.getXY()
button.device.drag((X,Y),(X,Y),2000年,1)

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:

buttonText = 'ClMe'
button = vc.findViewWithText(buttonText )
(x,y) = button.getXY()
button.device.drag((x,y), (x,y), 2000, 1)

这篇关于使用AndroidViewClient视图龙preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆