class Applitools::EyesMouse

Attributes

driver[R]
mouse[R]

Public Class Methods

new(driver, mouse) click to toggle source
# File lib/eyes_selenium_ruby/eyes/eyes_mouse.rb, line 4
def initialize(driver, mouse)
  @driver = driver
  @mouse = mouse
end

Public Instance Methods

click(element = nil) click to toggle source
# File lib/eyes_selenium_ruby/eyes/eyes_mouse.rb, line 9
def click(element = nil)
  extract_trigger_and_perform(:click, element)
end
context_click(element = nil) click to toggle source
# File lib/eyes_selenium_ruby/eyes/eyes_mouse.rb, line 17
def context_click(element = nil)
  extract_trigger_and_perform(:right_click, element)
end
double_click(element = nil) click to toggle source
# File lib/eyes_selenium_ruby/eyes/eyes_mouse.rb, line 13
def double_click(element = nil)
  extract_trigger_and_perform(:double_click, element)
end
down(element = nil) click to toggle source
# File lib/eyes_selenium_ruby/eyes/eyes_mouse.rb, line 21
def down(element = nil)
  extract_trigger_and_perform(:down, element)
end
move_by(right_by, down_by) click to toggle source
# File lib/eyes_selenium_ruby/eyes/eyes_mouse.rb, line 40
def move_by(right_by, down_by)
  right = [0,right_by].max
  down = [0,down_by].max
  location = Selenium::WebDriver::Location.new(right,down)
  current_control = Applitools::Region.new(0,0, right, down)
  driver.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) click to toggle source
# File lib/eyes_selenium_ruby/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
  location.y = [0,location.y].max
  current_control = Applitools::Region.new(0,0, *location.values)
  driver.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) click to toggle source
# File lib/eyes_selenium_ruby/eyes/eyes_mouse.rb, line 25
def up(element = nil)
  extract_trigger_and_perform(:up, element)
end

Private Instance Methods

extract_trigger_and_perform(method, element=nil, *args) click to toggle source
# File lib/eyes_selenium_ruby/eyes/eyes_mouse.rb, line 51
def extract_trigger_and_perform(method, element=nil, *args)
  location = element.location
  location.x = [0,location.x].max
  location.y = [0,location.y].max
  current_control = Applitools::Region.new(0,0, *location.values)
  driver.user_inputs << Applitools::MouseTrigger.new(method, current_control, location)
  element = element.web_element if element.is_a?(Applitools::Element)
  mouse.send(method,element,*args)
end