selenium.webdriver.common.actions.action_builder#
Classes
|
- class ActionBuilder(driver, mouse=None, wheel=None, keyboard=None, duration=250)[source]#
Bases:
object- Parameters:
mouse (PointerInput | None)
wheel (WheelInput | None)
keyboard (KeyInput | None)
duration (int)
- get_device_with(name)[source]#
Get the device with the given name.
- Parameters:
name (str) – The name of the device to get.
- Returns:
The device with the given name, or None if not found.
- Return type:
WheelInput | PointerInput | KeyInput | None
- property pointer_inputs: list[PointerInput]#
- property key_action: KeyActions#
- property pointer_action: PointerActions#
- property wheel_action: WheelActions#
- add_key_input(name)[source]#
Add a new key input device to the action builder.
- Parameters:
name (str) – The name of the key input device.
- Returns:
The newly created key input device.
- Return type:
Example
>>> action_builder = ActionBuilder(driver) >>> action_builder.add_key_input(name="keyboard2")
- add_pointer_input(kind, name)[source]#
Add a new pointer input device to the action builder.
- Parameters:
kind (str) – The kind of pointer input device. Valid values are “mouse”, “touch”, or “pen”.
name (str) – The name of the pointer input device.
- Returns:
The newly created pointer input device.
- Return type:
Example
>>> action_builder = ActionBuilder(driver) >>> action_builder.add_pointer_input(kind="mouse", name="mouse")
- add_wheel_input(name)[source]#
Add a new wheel input device to the action builder.
- Parameters:
name (str) – The name of the wheel input device.
- Returns:
The newly created wheel input device.
- Return type:
Example
>>> action_builder = ActionBuilder(driver) >>> action_builder.add_wheel_input(name="wheel2")
- perform()[source]#
Performs all stored actions.
Example
>>> action_builder = ActionBuilder(driver) >>> keyboard = action_builder.key_input >>> el = driver.find_element(id: "some_id") >>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys").perform()
- Return type:
None
- clear_actions()[source]#
Clears actions that are already stored on the remote end.
Example
>>> action_builder = ActionBuilder(driver) >>> keyboard = action_builder.key_input >>> el = driver.find_element(By.ID, "some_id") >>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys") >>> action_builder.clear_actions()
- Return type:
None