Class: Selenium::WebDriver::ActionBuilder
- Inherits:
-
Object
- Object
- Selenium::WebDriver::ActionBuilder
- Defined in:
- lib/selenium/webdriver/common/action_builder.rb
Instance Method Summary collapse
- #click(element = nil) ⇒ Object
- #click_and_hold(element) ⇒ Object
- #context_click(element = nil) ⇒ Object
- #double_click(element = nil) ⇒ Object
- #drag_and_drop(source, target) ⇒ Object
-
#initialize(mouse, keyboard) ⇒ ActionBuilder
constructor
A new instance of ActionBuilder.
- #key_down(*args) ⇒ Object
- #key_up(*args) ⇒ Object
- #move_by(down_by, right_by) ⇒ Object
- #move_to(element, down_by = nil, right_by = nil) ⇒ Object
- #perform ⇒ Object
- #release(element = nil) ⇒ Object
- #send_keys(*args) ⇒ Object
Constructor Details
#initialize(mouse, keyboard) ⇒ ActionBuilder
Returns a new instance of ActionBuilder.
5 6 7 8 9 10 11 12 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 5 def initialize(mouse, keyboard) @devices = { :mouse => mouse, :keyboard => keyboard } @actions = [] end |
Instance Method Details
#click(element = nil) ⇒ Object
51 52 53 54 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 51 def click(element = nil) @actions << [:mouse, :click, element] self end |
#click_and_hold(element) ⇒ Object
41 42 43 44 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 41 def click_and_hold(element) @actions << [:mouse, :down, element] self end |
#context_click(element = nil) ⇒ Object
76 77 78 79 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 76 def context_click(element = nil) @actions << [:mouse, :context_click, element] self end |
#double_click(element = nil) ⇒ Object
56 57 58 59 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 56 def double_click(element = nil) @actions << [:mouse, :double_click, element] self end |
#drag_and_drop(source, target) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 81 def drag_and_drop(source, target) click_and_hold source move_to target release target self end |
#key_down(*args) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 14 def key_down(*args) if args.first.kind_of? Element @actions << [:mouse, :click, args.shift] end @actions << [:keyboard, :press, args] self end |
#key_up(*args) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 23 def key_up(*args) if args.first.kind_of? Element @actions << [:mouse, :click, args.shift] end @actions << [:keyboard, :release, args] self end |
#move_by(down_by, right_by) ⇒ Object
71 72 73 74 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 71 def move_by(down_by, right_by) @actions << [:mouse, :move_by, down_by, right_by] self end |
#move_to(element, down_by = nil, right_by = nil) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 61 def move_to(element, down_by = nil, right_by = nil) if down_by && right_by @actions << [:mouse, :move_to, element, down_by, right_by] else @actions << [:mouse, :move_to, element] end self end |
#perform ⇒ Object
89 90 91 92 93 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 89 def perform @actions.each { |receiver, method, args| @devices.fetch(receiver).__send__(method, *args) } end |
#release(element = nil) ⇒ Object
46 47 48 49 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 46 def release(element = nil) @actions << [:mouse, :up, element] self end |
#send_keys(*args) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/selenium/webdriver/common/action_builder.rb', line 32 def send_keys(*args) if args.first.kind_of? Element @actions << [:mouse, :click, args.shift] end @actions << [:keyboard, :send_keys, args] self end |