selenium.webdriver.common.action_chains

The ActionChains implementation

class selenium.webdriver.common.action_chains.ActionChains(driver)[source]

Generate user actions. All actions are stored in the ActionChains object. Call perform() to fire stored actions.

Creates a new ActionChains.

Args :
  • driver: The WebDriver instance which performs user actions.
click(on_element=None)[source]

Clicks an element.

Args :
  • on_element: The element to click. If None, clicks on current mouse position.
click_and_hold(on_element=None)[source]

Holds down the left mouse button on an element.

Args :
  • on_element: The element to mouse down. If None, clicks on current mouse position.
context_click(on_element=None)[source]

Performs a context-click (right click) on an element.

Args :
  • on_element: The element to context-click. If None, clicks on current mouse position.
double_click(on_element=None)[source]

Double-clicks an element.

Args :
  • on_element: The element to double-click. If None, clicks on current mouse position.
drag_and_drop(source, target)[source]

Holds down the left mouse button on the source element, then moves to the target element and releases the mouse button.

Args :
  • source: The element to mouse down.
  • target: The element to mouse up.
drag_and_drop_by_offset(source, xoffset, yoffset)[source]
Holds down the left mouse button on the source element,
then moves to the target element and releases the mouse button.
Args :
  • source: The element to mouse down.
  • xoffset: X offset to move to.
  • yoffset: Y offset to move to.
key_down(value, element=None)[source]

Sends a key press only, without releasing it. Should only be used with modifier keys (Control, Alt and Shift).

Args :
  • key: The modifier key to send. Values are defined in Keys class.
  • target: The element to send keys. If None, sends a key to current focused element.
key_up(value, element=None)[source]

Releases a modifier key.

Args :
  • key: The modifier key to send. Values are defined in Keys class.
  • target: The element to send keys. If None, sends a key to current focused element.
move_by_offset(xoffset, yoffset)[source]

Moving the mouse to an offset from current mouse position.

Args :
  • xoffset: X offset to move to.
  • yoffset: Y offset to move to.
move_to_element(to_element)[source]

Moving the mouse to the middle of an element.

Args :
  • to_element: The element to move to.
move_to_element_with_offset(to_element, xoffset, yoffset)[source]

Move the mouse by an offset of the specificed element. Offsets are relative to the top-left corner of the element.

Args :
  • to_element: The element to move to.
  • xoffset: X offset to move to.
  • yoffset: Y offset to move to.
perform()[source]

Performs all stored actions.

release(on_element=None)[source]

Releasing a held mouse button.

Args :
  • on_element: The element to mouse up.
send_keys(*keys_to_send)[source]

Sends keys to current focused element.

Args :
  • keys_to_send: The keys to send.
send_keys_to_element(element, *keys_to_send)[source]

Sends keys to an element.

Args :
  • element: The element to send keys.
  • keys_to_send: The keys to send.

Previous topic

selenium.common.exceptions

Next topic

selenium.webdriver.common.alert

This Page