Skip to content

Commit 133cbec

Browse files
committed
[rb] implement duration parameter for ActionBuilder constructor
1 parent cd69898 commit 133cbec

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

rb/lib/selenium/webdriver/common/action_builder.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ class ActionBuilder
4343
#
4444

4545
def initialize(bridge, deprecated_mouse = nil, deprecated_keyboard = nil, deprecated_async = nil,
46-
devices: [], async: false)
46+
devices: [], async: false, duration: 250)
4747
@bridge = bridge
48+
@duration = duration
4849

4950
@async = if deprecated_async.nil?
5051
async

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ module PointerActions
2323
attr_writer :default_move_duration
2424

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

2930
def default_move_duration
30-
@default_move_duration ||= 0.25 # 250 milliseconds
31+
@default_move_duration ||= @duration / 1000 # convert ms to seconds
3132
end
3233

3334
#

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@
2020
module Selenium
2121
module WebDriver
2222
module WheelActions
23+
attr_writer :default_scroll_duration
24+
25+
#
26+
# By default this is set to 250ms in the ActionBuilder constructor
27+
# It can be overridden with default_scroll_duration=
28+
#
29+
2330
def default_scroll_duration
24-
@default_scroll_duration ||= 0.25 # 250 milliseconds
31+
@default_scroll_duration ||= @duration / 1000 # convert ms to seconds
2532
end
2633

2734
#

rb/lib/selenium/webdriver/remote/bridge.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ def delete_all_cookies
367367
# actions
368368
#
369369

370-
def action(deprecated_async = nil, async: false, devices: [])
371-
ActionBuilder.new self, nil, nil, deprecated_async, async: async, devices: devices
370+
def action(deprecated_async = nil, async: false, devices: [], duration: 250)
371+
ActionBuilder.new self, nil, nil, deprecated_async, async: async, devices: devices, duration: duration
372372
end
373373
alias_method :actions, :action
374374

0 commit comments

Comments
 (0)