|
21 | 21 | from selenium.webdriver.remote.webelement import WebElement |
22 | 22 |
|
23 | 23 | from .actions.action_builder import ActionBuilder |
| 24 | +from .actions.key_input import KeyInput |
| 25 | +from .actions.pointer_input import PointerInput |
24 | 26 | from .actions.wheel_input import ScrollOrigin |
| 27 | +from .actions.wheel_input import WheelInput |
25 | 28 | from .utils import keys_to_typing |
26 | 29 |
|
27 | 30 |
|
@@ -58,15 +61,26 @@ class ActionChains: |
58 | 61 | another. |
59 | 62 | """ |
60 | 63 |
|
61 | | - def __init__(self, driver, duration=250): |
| 64 | + def __init__(self, driver, duration=250, devices=None): |
62 | 65 | """Creates a new ActionChains. |
63 | 66 |
|
64 | 67 | :Args: |
65 | 68 | - driver: The WebDriver instance which performs user actions. |
66 | 69 | - duration: override the default 250 msecs of DEFAULT_MOVE_DURATION in PointerInput |
67 | 70 | """ |
68 | 71 | self._driver = driver |
69 | | - self.w3c_actions = ActionBuilder(driver, duration=duration) |
| 72 | + mouse = None |
| 73 | + keyboard = None |
| 74 | + wheel = None |
| 75 | + if devices is not None and isinstance(devices, list): |
| 76 | + for device in devices: |
| 77 | + if isinstance(device, PointerInput): |
| 78 | + mouse = device |
| 79 | + if isinstance(device, KeyInput): |
| 80 | + keyboard = device |
| 81 | + if isinstance(device, WheelInput): |
| 82 | + wheel = device |
| 83 | + self.w3c_actions = ActionBuilder(driver, mouse=mouse, keyboard=keyboard, wheel=wheel, duration=duration) |
70 | 84 |
|
71 | 85 | def perform(self): |
72 | 86 | """Performs all stored actions.""" |
|
0 commit comments