Skip to content

Commit b0057b5

Browse files
committed
[rb] allow specifying which button gets clicked in pointer action class methods
1 parent 60bf8e4 commit b0057b5

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

rb/lib/selenium/webdriver/common/interactions/pointer_actions.rb

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ def move_to_location(x, y, device: nil, duration: default_move_duration, **opts)
192192
# @return [ActionBuilder] A self reference.
193193
#
194194

195-
def click_and_hold(element = nil, device: nil)
195+
def click_and_hold(element = nil, button: nil, device: nil)
196196
move_to(element, device: device) if element
197-
pointer_down(:left, device: device)
197+
pointer_down(button || :left, device: device)
198198
self
199199
end
200200

@@ -211,8 +211,8 @@ def click_and_hold(element = nil, device: nil)
211211
# @return [ActionBuilder] A self reference.
212212
#
213213

214-
def release(device: nil)
215-
pointer_up(:left, device: device)
214+
def release(button: nil, device: nil)
215+
pointer_up(button || :left, device: device)
216216
self
217217
end
218218

@@ -238,10 +238,10 @@ def release(device: nil)
238238
# @return [ActionBuilder] A self reference.
239239
#
240240

241-
def click(element = nil, device: nil)
241+
def click(element = nil, button: nil, device: nil)
242242
move_to(element, device: device) if element
243-
pointer_down(:left, device: device)
244-
pointer_up(:left, device: device)
243+
pointer_down(button || :left, device: device)
244+
pointer_up(button || :left, device: device)
245245
self
246246
end
247247

@@ -296,10 +296,7 @@ def double_click(element = nil, device: nil)
296296
#
297297

298298
def context_click(element = nil, device: nil)
299-
move_to(element, device: device) if element
300-
pointer_down(:right, device: device)
301-
pointer_up(:right, device: device)
302-
self
299+
click(element, button: :right, device: device)
303300
end
304301

305302
#

0 commit comments

Comments
 (0)