Skip to content

Commit

Permalink
use fill pause util, add fill pause to scroll(wheel) methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kkb912002 committed Mar 19, 2024
1 parent 312a34e commit 324a656
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions py/selenium/webdriver/common/action_chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ def click(self, on_element: WebElement | None = None) -> ActionChains:
self.move_to_element(on_element)

self.w3c_actions.pointer_action.click()
self.w3c_actions.key_action.pause()
self.w3c_actions.key_action.pause()
self.w3c_actions.fill_pause_except('pointer', 2)

return self

Expand All @@ -127,7 +126,7 @@ def click_and_hold(self, on_element: WebElement | None = None) -> ActionChains:
self.move_to_element(on_element)

self.w3c_actions.pointer_action.click_and_hold()
self.w3c_actions.key_action.pause()
self.w3c_actions.fill_pause_except('pointer')

return self

Expand All @@ -142,8 +141,7 @@ def context_click(self, on_element: WebElement | None = None) -> ActionChains:
self.move_to_element(on_element)

self.w3c_actions.pointer_action.context_click()
self.w3c_actions.key_action.pause()
self.w3c_actions.key_action.pause()
self.w3c_actions.fill_pause_except('pointer', 2)

return self

Expand All @@ -158,8 +156,7 @@ def double_click(self, on_element: WebElement | None = None) -> ActionChains:
self.move_to_element(on_element)

self.w3c_actions.pointer_action.double_click()
for _ in range(4):
self.w3c_actions.key_action.pause()
self.w3c_actions.fill_pause_except('pointer', 4)

return self

Expand Down Expand Up @@ -206,7 +203,7 @@ def key_down(self, value: str, element: WebElement | None = None) -> ActionChain
self.click(element)

self.w3c_actions.key_action.key_down(value)
self.w3c_actions.pointer_action.pause()
self.w3c_actions.fill_pause_except('key')

return self

Expand All @@ -226,7 +223,7 @@ def key_up(self, value: str, element: WebElement | None = None) -> ActionChains:
self.click(element)

self.w3c_actions.key_action.key_up(value)
self.w3c_actions.pointer_action.pause()
self.w3c_actions.fill_pause_except('key')

return self

Expand All @@ -239,7 +236,7 @@ def move_by_offset(self, xoffset: int, yoffset: int) -> ActionChains:
"""

self.w3c_actions.pointer_action.move_by(xoffset, yoffset)
self.w3c_actions.key_action.pause()
self.w3c_actions.fill_pause_except('pointer')

return self

Expand All @@ -251,7 +248,7 @@ def move_to_element(self, to_element: WebElement) -> ActionChains:
"""

self.w3c_actions.pointer_action.move_to(to_element)
self.w3c_actions.key_action.pause()
self.w3c_actions.fill_pause_except('pointer')

return self

Expand All @@ -266,15 +263,16 @@ def move_to_element_with_offset(self, to_element: WebElement, xoffset: int, yoff
"""

self.w3c_actions.pointer_action.move_to(to_element, int(xoffset), int(yoffset))
self.w3c_actions.key_action.pause()
self.w3c_actions.fill_pause_except('pointer')

return self

def pause(self, seconds: float | int) -> ActionChains:
"""Pause all inputs for the specified duration in seconds."""

self.w3c_actions.pointer_action.pause(seconds)
self.w3c_actions.key_action.pause(seconds)
self.w3c_actions.pointer_action.pause(seconds)
self.w3c_actions.wheel_action.pause(seconds)

return self

Expand All @@ -289,7 +287,7 @@ def release(self, on_element: WebElement | None = None) -> ActionChains:
self.move_to_element(on_element)

self.w3c_actions.pointer_action.release()
self.w3c_actions.key_action.pause()
self.w3c_actions.fill_pause_except('pointer')

return self

Expand Down Expand Up @@ -329,6 +327,8 @@ def scroll_to_element(self, element: WebElement) -> ActionChains:
"""

self.w3c_actions.wheel_action.scroll(origin=element)
self.w3c_actions.fill_pause_except('wheel')

return self

def scroll_by_amount(self, delta_x: int, delta_y: int) -> ActionChains:
Expand All @@ -341,6 +341,8 @@ def scroll_by_amount(self, delta_x: int, delta_y: int) -> ActionChains:
"""

self.w3c_actions.wheel_action.scroll(delta_x=delta_x, delta_y=delta_y)
self.w3c_actions.fill_pause_except('wheel')

return self

def scroll_from_origin(self, scroll_origin: ScrollOrigin, delta_x: int, delta_y: int) -> ActionChains:
Expand Down Expand Up @@ -369,6 +371,8 @@ def scroll_from_origin(self, scroll_origin: ScrollOrigin, delta_x: int, delta_y:
delta_x=delta_x,
delta_y=delta_y,
)
self.w3c_actions.fill_pause_except('wheel')

return self

# Context manager so ActionChains can be used in a 'with .. as' statements.
Expand Down

0 comments on commit 324a656

Please sign in to comment.