selenium.webdriver.common.actions.action_builder¶
Classes
|
- class selenium.webdriver.common.actions.action_builder.ActionBuilder(driver, mouse: PointerInput | None = None, wheel: WheelInput | None = None, keyboard: KeyInput | None = None, duration: int = 250)[source]¶
- get_device_with(name: str) WheelInput | PointerInput | KeyInput | None[source]¶
Get the device with the given name.
- Args:
name: The name of the device to get.
- Returns:
The device with the given name, or None if not found.
- property pointer_inputs: list[PointerInput]¶
- property key_action: KeyActions¶
- property pointer_action: PointerActions¶
- property wheel_action: WheelActions¶
- add_key_input(name: str) KeyInput[source]¶
Add a new key input device to the action builder.
- Args:
name: The name of the key input device.
- Returns:
The newly created key input device.
- Example:
>>> action_builder = ActionBuilder(driver) >>> action_builder.add_key_input(name="keyboard2")
- add_pointer_input(kind: str, name: str) PointerInput[source]¶
Add a new pointer input device to the action builder.
- Args:
- kind: The kind of pointer input device. Valid values are “mouse”,
“touch”, or “pen”.
name: The name of the pointer input device.
- Returns:
The newly created pointer input device.
- Example:
>>> action_builder = ActionBuilder(driver) >>> action_builder.add_pointer_input(kind="mouse", name="mouse")
- add_wheel_input(name: str) WheelInput[source]¶
Add a new wheel input device to the action builder.
- Args:
name: The name of the wheel input device.
- Returns:
The newly created wheel input device.
- Example:
>>> action_builder = ActionBuilder(driver) >>> action_builder.add_wheel_input(name="wheel2")
- perform() None[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()
- clear_actions() None[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()