Class: Applitools::EyesMouse
- Inherits:
-
Object
- Object
- Applitools::EyesMouse
- Defined in:
- lib/eyes_selenium/eyes/eyes_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) ⇒ EyesMouse
constructor
A new instance of EyesMouse.
- #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) ⇒ EyesMouse
Returns a new instance of EyesMouse.
4 5 6 7 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 4 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/eyes_selenium/eyes/eyes_mouse.rb', line 3 def driver @driver end |
#mouse ⇒ Object (readonly)
Returns the value of attribute mouse.
3 4 5 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 3 def mouse @mouse end |
Instance Method Details
#click(element = nil) ⇒ Object
9 10 11 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 9 def click(element = nil) extract_trigger_and_perform(:click, element) end |
#context_click(element = nil) ⇒ Object
17 18 19 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 17 def context_click(element = nil) extract_trigger_and_perform(:right_click, element) end |
#double_click(element = nil) ⇒ Object
13 14 15 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 13 def double_click(element = nil) extract_trigger_and_perform(:double_click, element) end |
#down(element = nil) ⇒ Object
21 22 23 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 21 def down(element = nil) extract_trigger_and_perform(:down, element) end |
#move_by(right_by, down_by) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 40 def move_by(right_by, down_by) right = [0,right_by].max.round down = [0,down_by].max.round location = Selenium::WebDriver::Point.new(right,down) current_control = Applitools::Region.new(0,0, right, down) driver.eyes.user_inputs << Applitools::MouseTrigger.new(:move, current_control, location) mouse.move_by(right_by,down_by) end |
#move_to(element, right_by = nil, down_by = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 29 def move_to(element, right_by = nil, down_by = nil) element = element.web_element if element.is_a?(Applitools::Element) location = element.location location.x = [0,location.x].max.round location.y = [0,location.y].max.round current_control = Applitools::Region.new(0,0, *location.values) driver.eyes.user_inputs << Applitools::MouseTrigger.new(:move, current_control, location) element = element.web_element if element.is_a?(Applitools::Element) mouse.move_to(element,right_by, down_by) end |
#up(element = nil) ⇒ Object
25 26 27 |
# File 'lib/eyes_selenium/eyes/eyes_mouse.rb', line 25 def up(element = nil) extract_trigger_and_perform(:up, element) end |