MCPcopy
hub / github.com/AirtestProject/Poco / swipe

Method swipe

poco/proxy.py:432–461  ·  view source on GitHub ↗

Perform a swipe action given by the direction from this UI element. For notices and limitations see :py:meth:`.click() `. Args: direction (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): coordinates (x, y) in NormalizedCoordinate syst

(self, direction, focus=None, duration=0.5)

Source from the content-addressed store, hash-verified

430
431 @wait
432 def swipe(self, direction, focus=None, duration=0.5):
433 """
434 Perform a swipe action given by the direction from this UI element. For notices and limitations see
435 :py:meth:`.click() <poco.proxy.UIObjectProxy.click>`.
436
437 Args:
438 direction (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): coordinates (x, y) in NormalizedCoordinate system, it
439 can be also specified as 'up', 'down', 'left', 'right'. Swipe 'up' is equivalent to [0, -0.1], swipe
440 'down' is equivalent to [0, 0.1], swipe 'left' is equivalent to [-0.1, 0] and swipe 'right' is equivalent
441 to [0.1, 0]
442 focus (2-:obj:`tuple`/2-:obj:`list`/:obj:`str`): see :py:meth:`.click() <poco.proxy.UIObjectProxy.click>`
443 for more details
444 duration (:py:obj:`float`): time interval in which the action is performed
445
446 Raises:
447 PocoNoSuchNodeException: raised when the UI element does not exist
448 """
449
450 try:
451 duration = float(duration)
452 except ValueError:
453 raise ValueError('Argument `duration` should be <float>. Got {}'.format(repr(duration)))
454
455 focus = focus or self._focus or 'center'
456 dir_vec = self._direction_vector_of(direction)
457 origin = self.get_position(focus)
458 self.poco.pre_action('swipe', self, (origin, dir_vec))
459 ret = self.poco.swipe(origin, direction=dir_vec, duration=duration)
460 self.poco.post_action('swipe', self, (origin, dir_vec))
461 return ret
462
463 def drag_to(self, target, duration=2.0):
464 """

Callers 1

drag_toMethod · 0.95

Calls 4

_direction_vector_ofMethod · 0.95
get_positionMethod · 0.95
pre_actionMethod · 0.80
post_actionMethod · 0.80

Tested by

no test coverage detected