HENNGE / arsenic

Async WebDriver implementation for asyncio and asyncio-compatible frameworks
Other
350 stars 54 forks source link

Chained actions #6

Closed ojii closed 7 years ago

ojii commented 7 years ago

Re-wrote the action-chain API. New API:


from arsenic.actions import Mouse, Keyboard, chain

mouse = Mouse()
keyboard = Keyboard()
actions = chain(
    mouse.move_to(element) & keyboard.down('a'),
    mouse.down(),
    mouse.move_by(100, 50),
    mouse.up() & keyboard.up('a')
)
await session.perform_actions(actions)

Other input devices are Keyboard, Pen and Touch (the latter two seem to not really be supported by browsers yet). Individual actions such as mouse.down() can be "and"-ed with actions on other input devices to have them perform at the same time (details depend on the browser), so if your browser supports Touch, you can do multi-touch action chains.

There's also an attempt to make this work with browsers that don't support the 'actions' api at all.

Note: seems to be broken on remote-firefox.