Class: Applitools::Selenium::Mouse
- Inherits:
-
Object
- Object
- Applitools::Selenium::Mouse
- Defined in:
- lib/applitools/selenium/mouse.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
-
#mouse ⇒ Object
readonly
Returns the value of attribute mouse.
Instance Method Summary collapse
- #click(element = nil) ⇒ Object
- #context_click(element = nil) ⇒ Object
- #double_click(element = nil) ⇒ Object
- #down(element = nil) ⇒ Object
-
#initialize(driver, mouse) ⇒ Mouse
constructor
A new instance of Mouse.
- #move_by(right_by, down_by) ⇒ Object
- #move_to(element, right_by = nil, down_by = nil) ⇒ Object
- #up(element = nil) ⇒ Object
Constructor Details
#initialize(driver, mouse) ⇒ Mouse
Returns a new instance of Mouse.
5 6 7 8 |
# File 'lib/applitools/selenium/mouse.rb', line 5 def initialize(driver, mouse) @driver = driver @mouse = mouse end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
3 4 5 |
# File 'lib/applitools/selenium/mouse.rb', line 3 def driver @driver end |
#mouse ⇒ Object (readonly)
Returns the value of attribute mouse.
3 4 5 |
# File 'lib/applitools/selenium/mouse.rb', line 3 def mouse @mouse end |
Instance Method Details
#click(element = nil) ⇒ Object
10 11 12 |
# File 'lib/applitools/selenium/mouse.rb', line 10 def click(element = nil) extract_trigger_and_perform(:click, element) end |
#context_click(element = nil) ⇒ Object
18 19 20 |
# File 'lib/applitools/selenium/mouse.rb', line 18 def context_click(element = nil) extract_trigger_and_perform(:right_click, element) end |
#double_click(element = nil) ⇒ Object
14 15 16 |
# File 'lib/applitools/selenium/mouse.rb', line 14 def double_click(element = nil) extract_trigger_and_perform(:double_click, element) end |
#down(element = nil) ⇒ Object
22 23 24 |
# File 'lib/applitools/selenium/mouse.rb', line 22 def down(element = nil) extract_trigger_and_perform(:down, element) end |
#move_by(right_by, down_by) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/applitools/selenium/mouse.rb', line 41 def move_by(right_by, down_by) right = [0, right_by].max.round down = [0, down_by].max.round location = Applitools::Base::Point.new(right, down) current_control = Applitools::Base::Region.new(0, 0, right, down) driver.user_inputs << Applitools::Base::MouseTrigger.new(:move, current_control, location) mouse.move_by(right_by, down_by) end |
#move_to(element, right_by = nil, down_by = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/applitools/selenium/mouse.rb', line 30 def move_to(element, right_by = nil, down_by = nil) element = element.web_element if element.is_a?(Applitools::Selenium::Element) location = element.location location.x = [0, location.x].max.round location.y = [0, location.y].max.round current_control = Applitools::Base::Region.new(0, 0, *location.values) driver.user_inputs << Applitools::Base::MouseTrigger.new(:move, current_control, location) element = element.web_element if element.is_a?(Applitools::Selenium::Element) mouse.move_to(element, right_by, down_by) end |
#up(element = nil) ⇒ Object
26 27 28 |
# File 'lib/applitools/selenium/mouse.rb', line 26 def up(element = nil) extract_trigger_and_perform(:up, element) end |