我有一个脚本,它可以找到一个文本视图,获取它的坐标并单击它。为了点击,我必须滚动并找到文本视图。脚本如下:
text = 'abc'
self.device.drag((400,600), (300, 200), 0.01, 120)
tv = self.vc.findViewWithText(text)
if tv:
(x, y) = tv.getXY()
print >>sys.stderr, "Clicking TextView %s @ (%d,%d) ..." % (text, x, y)
tv.touch()
else:
print "Text is not found" %text
它可以拖动。虽然存在文本“abc”,但它打印“找不到文本”。在
我删除了drag()方法,并手动进行了拖动,它工作得很好(识别文本并进行了单击)。在
有人知道我的drag()方法有什么问题吗。在
谢谢
MonkeyRunner执行所有命令的速度非常快,因此在它开始查找视图之前,您必须添加睡眠。所以你的代码应该是。在
AndroidViewClient.dump()
转储当前显示在屏幕上的内容,因此,如果必须滚动以使TextView
可见,则不会出现在第一个(隐式)转储中。 因此,您必须在滚动后再次转储:或者
^{pr2}$还要考虑到NRP提到的关于睡眠的问题。在
相关问题 更多 >
编程相关推荐