How to use the arsenic.errors.OperationNotSupported 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_real_browsers.py View on Github external
isinstance(session, CompatSession)
        else
        null_context
    )
    await session.get('/actions/')

    output = await session.wait_for_element(5, '#output')
    assert '' == await output.get_text()

    mouse = Mouse()
    keyboard = Keyboard()
    canvas = await session.get_element('#canvas')

    # keyboard actions cannot be emulated in non-w3c drivers
    ctx = (
        pytest.raises(OperationNotSupported)
        if
        isinstance(session, CompatSession)
        else
        null_context()
    )

    with ctx:
        actions = chain(
            mouse.move_to(canvas),
            mouse.down() & keyboard.down('a'),
            mouse.move_by(10, 20) & keyboard.up('a'),
            mouse.up()
        )
        await check(actions, '')

        actions = chain(
github HDE / arsenic / tests / test_real_browsers.py View on Github external
await session.get("/actions/")
    output = await session.wait_for_element(5, "#output")
    assert "" == await output.get_text()

    await session.get("/actions/")

    output = await session.wait_for_element(5, "#output")
    assert "" == await output.get_text()

    mouse = Mouse()
    keyboard = Keyboard()
    canvas = await session.get_element("#canvas")

    # keyboard actions cannot be emulated in non-w3c drivers
    ctx = (
        pytest.raises(OperationNotSupported)
        if isinstance(session, CompatSession)
        else null_context()
    )

    with ctx:
        actions = chain(
            mouse.move_to(canvas),
            mouse.down() & keyboard.down("a"),
            mouse.move_by(10, 20) & keyboard.up("a"),
            mouse.up(),
        )
        await check(actions, "")

        actions = chain(
            mouse.move_to(canvas),
            mouse.down(),
github HDE / arsenic / tests / test_real_browsers.py View on Github external
if isinstance(session.browser, Firefox) and isinstance(session.service, Remote):
        pytest.xfail('remote firefox actions do not work')

    async def check(actions, expected):
        await session.perform_actions(actions)
        output = await session.get_element('#output')
        assert expected == await output.get_text()

    await session.get('/actions/')
    output = await session.wait_for_element(5, '#output')
    assert '' == await output.get_text()
    mouse = Mouse()
    keyboard = Keyboard()
    canvas = await session.get_element('#canvas')
    ctx = (
        pytest.raises(OperationNotSupported)
        if
        isinstance(session, CompatSession)
        else
        null_context
    )
    await session.get('/actions/')

    output = await session.wait_for_element(5, '#output')
    assert '' == await output.get_text()

    mouse = Mouse()
    keyboard = Keyboard()
    canvas = await session.get_element('#canvas')

    # keyboard actions cannot be emulated in non-w3c drivers
    ctx = (
github HDE / arsenic / src / arsenic / session.py View on Github external
def transform_legacy_actions(
    devices: List[Dict[str, Any]]
) -> Iterator[Tuple[str, str, Dict[str, Any]]]:
    for legacy_action in get_legacy_actions(devices):
        device_type = legacy_action.device["type"]
        action_type = legacy_action.action["type"]
        device = {
            key: value for key, value in legacy_action.device.items() if key != "type"
        }
        action = {
            key: value for key, value in legacy_action.action.items() if key != "type"
        }
        try:
            handler = legacy_actions[(device_type, action_type)]
        except KeyError:
            raise OperationNotSupported(
                f"Unsupported action {action_type} for device_type {device_type}"
            )
        action = handler(device, action)
        if action is not None:
            yield action
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