Skip to content

Commit

Permalink
[py] allow specifying which button gets clicked in pointer action cla…
Browse files Browse the repository at this point in the history
…ss methods
  • Loading branch information
titusfortner committed Jun 1, 2022
1 parent 6afbbcf commit 60bf8e4
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions py/selenium/webdriver/common/actions/pointer_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,24 @@ def move_to_location(self, x, y, width=None, height=None, pressure=None,
altitude_angle=altitude_angle, azimuth_angle=azimuth_angle)
return self

def click(self, element=None):
def click(self, element=None, button=MouseButton.LEFT):
if element:
self.move_to(element)
self.pointer_down(MouseButton.LEFT)
self.pointer_up(MouseButton.LEFT)
self.pointer_down(button)
self.pointer_up(button)
return self

def context_click(self, element=None):
if element:
self.move_to(element)
self.pointer_down(MouseButton.RIGHT)
self.pointer_up(MouseButton.RIGHT)
return self
return self.click(element=element, button=MouseButton.RIGHT)

def click_and_hold(self, element=None):
def click_and_hold(self, element=None, button=MouseButton.LEFT):
if element:
self.move_to(element)
self.pointer_down()
self.pointer_down(button=button)
return self

def release(self):
self.pointer_up()
def release(self, button=MouseButton.LEFT):
self.pointer_up(button=button)
return self

def double_click(self, element=None):
Expand Down

0 comments on commit 60bf8e4

Please sign in to comment.