How to use the arsenic.constants function in arsenic

To help you get started, we’ve selected a few arsenic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HDE / arsenic / tests / test_actions.py View on Github external
def test_drag_n_drop():
    mouse = Mouse()
    actions = chain(
        mouse.move_to(ELEMENT_ONE), mouse.down(), mouse.move_by(100, 100), mouse.up()
    )
    assert actions == {
        "actions": [
            {
                "parameters": {"pointerType": "mouse"},
                "id": "pointer1",
                "type": "pointer",
                "actions": [
                    {
                        "type": "pointerMove",
                        "duration": 250,
                        "origin": {constants.WEB_ELEMENT: "1"},
                        "x": 0,
                        "y": 0,
                    },
                    {"type": "pointerDown", "duration": 0, "button": 0},
                    {
                        "type": "pointerMove",
                        "duration": 250,
                        "origin": "pointer",
                        "x": 100,
                        "y": 100,
                    },
                    {"type": "pointerUp", "duration": 0, "button": 0},
                ],
github HDE / arsenic / src / arsenic / session.py View on Github external
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
github HDE / arsenic / src / arsenic / connection.py View on Github external
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