Drag and Swipe operations
Like click, drag and swipe are other types of actions on UI. Drag usually starts from and ends to specific UI, while Swipe can be performed from any point to any point.
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
See also: