Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
finger1.move_to(ELEMENT_ONE) & finger2.move_to(ELEMENT_TWO),
finger1.down() & finger2.down(),
finger2.move_to(ELEMENT_TRI),
finger1.up() & finger2.up(),
)
devices = list(sorted(actions["actions"], key=itemgetter("id")))
assert devices == [
{
"parameters": {"pointerType": "touch"},
"id": "pointer1",
"type": "pointer",
"actions": [
{
"type": "pointerMove",
"duration": 250,
"origin": {constants.WEB_ELEMENT: "1"},
"x": 0,
"y": 0,
},
{"type": "pointerDown", "duration": 0, "button": 0},
# create implicitly
{"type": "pause", "duration": 0},
{"type": "pointerUp", "duration": 0, "button": 0},
],
},
{
"parameters": {"pointerType": "touch"},
"id": "pointer2",
"type": "pointer",
"actions": [
{
"type": "pointerMove",
def move_to(self, element: Element, duration: int=250) -> Tick:
return self._tick(
type='pointerMove',
duration=duration,
origin={constants.WEB_ELEMENT: element.id},
x=0,
y=0,
)
def unwrap(value):
if isinstance(value, dict) and (
'ELEMENT' in value or constants.WEB_ELEMENT in value):
wrapped_id = value.get('ELEMENT', None)
if wrapped_id:
return value['ELEMENT']
else:
return value[constants.WEB_ELEMENT]
elif isinstance(value, list):
return list(unwrap(item) for item in value)
else:
return value
def _pointer_move(device, action):
del action["duration"]
url = "/moveto" if device["parameters"]["pointerType"] == "mouse" else "/touch/move"
origin = action["origin"]
if origin == "pointer":
data = {"xoffset": action["x"], "yoffset": action["y"]}
elif constants.WEB_ELEMENT in origin:
data = {"element": origin[constants.WEB_ELEMENT]}
else:
raise OperationNotSupported(f"Cannot move using origin {origin}")
return url, "POST", data