Action Chains

Arsenic supports action chains that allow you to define a sequence of mouse and/or keyboard actions to perform in sequence (and in parallel).

Note

Action chains are only supported by a few browsers so far. For other browsers, arsenic will attempt to emulate them using older APIs, however it can only emulate a single mouse input.

Drag and drop

Drag and drop functionality can be implemented using arsenic.actions.Mouse together with arsenic.actions.chain() and arsenic.session.Session.preform_actions().

Here is an example helper function which moves the mouse to an element and drags it by a specified amount of pixels:

from arsenic.actions import Mouse, chain
from arsenic.session import Element, Session


async def drag_and_drop(session: Session, source_element: Element, x_offset: int, y_offset: int):
    mouse = Mouse()
    actions = chain(
        mouse.move_to(source_element),
        mouse.down(),
        mouse.move_by(x_offset, y_offset),
        mouse.up(),
    )
    await session.perform_actions(actions)