拖动和滑动(drag/swipe)¶
和点击一样,拖动和滑动也是常规UI操作,拖动 是从一个UI到另一个UI,滑动 是从一个UI开始,滑动到某个点或朝着某个方向滑动一段距离。其实本质上,拖动是滑动的特殊情况。
Drag¶
The following example shows how to swipe or drag the “star” to the “shell”.

# coding=utf-8
from poco.drivers.unity3d import UnityPoco
poco = UnityPoco()
# drag the "star" to the "shell"
poco('star').drag_to(poco('shell'))
Swipe¶
The following example shows how to scroll a list by using swipe.

# coding=utf-8
from poco.drivers.unity3d import UnityPoco
poco = UnityPoco()
# swipe the list view up
poco('Scroll View').swipe([0, -0.1])
poco('Scroll View').swipe('up') # the same as above, also have down/left/right
poco('Scroll View').swipe('down')
# perform swipe without UI selected
x, y = poco('Scroll View').get_position()
end = [x, y - 0.1]
dir = [0, -0.1]
poco.swipe([x, y], end) # drag from point A to point B
poco.swipe([x, y], direction=dir) # drag from point A toward given direction and length
更多示例: