Skip to content

Commit

Permalink
[py] Allow setting a different pointer, keyboard, or wheel on input d…
Browse files Browse the repository at this point in the history
…evice (#11521)

[py] Allow using device parameter in ActionChains constructor
  • Loading branch information
TamsilAmani committed May 31, 2023
1 parent f7d3df2 commit 8a73d50
Show file tree
Hide file tree
Showing 2 changed files with 390 additions and 2 deletions.
18 changes: 16 additions & 2 deletions py/selenium/webdriver/common/action_chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
from selenium.webdriver.remote.webelement import WebElement

from .actions.action_builder import ActionBuilder
from .actions.key_input import KeyInput
from .actions.pointer_input import PointerInput
from .actions.wheel_input import ScrollOrigin
from .actions.wheel_input import WheelInput
from .utils import keys_to_typing


Expand Down Expand Up @@ -58,15 +61,26 @@ class ActionChains:
another.
"""

def __init__(self, driver, duration=250):
def __init__(self, driver, duration=250, devices=None):
"""Creates a new ActionChains.
:Args:
- driver: The WebDriver instance which performs user actions.
- duration: override the default 250 msecs of DEFAULT_MOVE_DURATION in PointerInput
"""
self._driver = driver
self.w3c_actions = ActionBuilder(driver, duration=duration)
mouse = None
keyboard = None
wheel = None
if devices is not None and isinstance(devices, list):
for device in devices:
if isinstance(device, PointerInput):
mouse = device
if isinstance(device, KeyInput):
keyboard = device
if isinstance(device, WheelInput):
wheel = device
self.w3c_actions = ActionBuilder(driver, mouse=mouse, keyboard=keyboard, wheel=wheel, duration=duration)

def perform(self):
"""Performs all stored actions."""
Expand Down
Loading

0 comments on commit 8a73d50

Please sign in to comment.