Class: Capybara::Apparition::Mouse
- Inherits:
-
Object
- Object
- Capybara::Apparition::Mouse
- Defined in:
- lib/capybara/apparition/page/mouse.rb
Instance Method Summary collapse
- #click_at(x:, y:, button: 'left', count: 1, modifiers: []) ⇒ Object
- #down(button: 'left', **options) ⇒ Object
-
#initialize(page, keyboard) ⇒ Mouse
constructor
A new instance of Mouse.
- #move_to(x:, y:, **options) ⇒ Object
- #up(button: 'left', **options) ⇒ Object
Constructor Details
#initialize(page, keyboard) ⇒ Mouse
Returns a new instance of Mouse.
5 6 7 8 9 |
# File 'lib/capybara/apparition/page/mouse.rb', line 5 def initialize(page, keyboard) @page = page @keyboard = keyboard @current_pos = { x: 0, y: 0 } end |
Instance Method Details
#click_at(x:, y:, button: 'left', count: 1, modifiers: []) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/capybara/apparition/page/mouse.rb', line 11 def click_at(x:, y:, button: 'left', count: 1, modifiers: []) move_to x: x, y: y count.times do |num| @keyboard.with_keys(modifiers) do mouse_params = { x: x, y: y, button: , count: num + 1 } down mouse_params up mouse_params end end self end |
#down(button: 'left', **options) ⇒ Object
29 30 31 32 33 |
# File 'lib/capybara/apparition/page/mouse.rb', line 29 def down(button: 'left', **) = @current_pos.merge(button: ).merge() mouse_event('mousePressed', ) self end |
#move_to(x:, y:, **options) ⇒ Object
23 24 25 26 27 |
# File 'lib/capybara/apparition/page/mouse.rb', line 23 def move_to(x:, y:, **) @current_pos = { x: x, y: y } mouse_event('mouseMoved', x: x, y: y, **) self end |
#up(button: 'left', **options) ⇒ Object
35 36 37 38 39 |
# File 'lib/capybara/apparition/page/mouse.rb', line 35 def up(button: 'left', **) = @current_pos.merge(button: ).merge() mouse_event('mouseReleased', ) self end |