Bug 1345653 - Add pause and click to actions client API; r=ato

MozReview-Commit-ID: 9yMUtEWt2tx
This commit is contained in:
Maja Frydrychowicz 2017-04-04 00:01:43 -04:00 коммит произвёл James Graham
Родитель d7e6aa0db8
Коммит 4b64f1dcc1
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -121,6 +121,10 @@ class ActionSequence(object):
def _pointer_action(self, subtype, button):
self._actions.append({"type": subtype, "button": button})
def pause(self, duration):
self._actions.append({"type": "pause", "duration": duration})
return self
def pointer_move(self, x, y, duration=None, origin=None):
"""Queue a pointerMove action.
@ -159,6 +163,20 @@ class ActionSequence(object):
self._pointer_action("pointerDown", button)
return self
def click(self, element=None, button=0):
"""Queue a click with the specified button.
If an element is given, move the pointer to that element first,
otherwise click current pointer coordinates.
:param element: Optional element to click.
:param button: Integer representing pointer button to perform action
with. Default: 0, which represents main device button.
"""
if element:
self.pointer_move(0, 0, origin=element)
return self.pointer_down(button).pointer_up(button)
def key_up(self, value):
"""Queue a keyUp action for `value`.