Skip to content

Commit

Permalink
[rb] implement duration parameter for ActionBuilder constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed May 25, 2022
1 parent cd69898 commit 133cbec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion rb/lib/selenium/webdriver/common/action_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class ActionBuilder
#

def initialize(bridge, deprecated_mouse = nil, deprecated_keyboard = nil, deprecated_async = nil,
devices: [], async: false)
devices: [], async: false, duration: 250)
@bridge = bridge
@duration = duration

@async = if deprecated_async.nil?
async
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ module PointerActions
attr_writer :default_move_duration

#
# The overridable duration for movement used by methods in this module
# By default this is set to 250ms in the ActionBuilder constructor
# It can be overridden with default_move_duration=
#

def default_move_duration
@default_move_duration ||= 0.25 # 250 milliseconds
@default_move_duration ||= @duration / 1000 # convert ms to seconds
end

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@
module Selenium
module WebDriver
module WheelActions
attr_writer :default_scroll_duration

#
# By default this is set to 250ms in the ActionBuilder constructor
# It can be overridden with default_scroll_duration=
#

def default_scroll_duration
@default_scroll_duration ||= 0.25 # 250 milliseconds
@default_scroll_duration ||= @duration / 1000 # convert ms to seconds
end

#
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/remote/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ def delete_all_cookies
# actions
#

def action(deprecated_async = nil, async: false, devices: [])
ActionBuilder.new self, nil, nil, deprecated_async, async: async, devices: devices
def action(deprecated_async = nil, async: false, devices: [], duration: 250)
ActionBuilder.new self, nil, nil, deprecated_async, async: async, devices: devices, duration: duration
end
alias_method :actions, :action

Expand Down

0 comments on commit 133cbec

Please sign in to comment.