class Applitools::Element

Constants

ELEMENT_METHODS

Attributes

driver[RW]
web_element[RW]

Public Class Methods

new(driver, element) click to toggle source
# File lib/eyes_selenium_ruby/eyes/element.rb, line 23
def initialize(driver, element)
  @driver = driver
  @web_element = element
end

Public Instance Methods

==(other) click to toggle source
# File lib/eyes_selenium_ruby/eyes/element.rb, line 40
def ==(other)
  other.kind_of?(web_element.class) && web_element == other
end
Also aliased as: eql?
click() click to toggle source
# File lib/eyes_selenium_ruby/eyes/element.rb, line 28
def click
  current_control = region
  offset = current_control.middle_offset
  driver.user_inputs << Applitools::MouseTrigger.new(:click, current_control, offset)

  web_element.click
end
eql?(other)
Alias for: ==
inspect() click to toggle source
# File lib/eyes_selenium_ruby/eyes/element.rb, line 36
def inspect
  "EyesWebElement" + web_element.inspect
end
region() click to toggle source
# File lib/eyes_selenium_ruby/eyes/element.rb, line 55
def region
  point = location
  left, top, width, height  = point.x, point.y, 0, 0

  begin
    dimension = size
    width, height = dimension.width, dimension.height 
  rescue
    # Not supported on all platforms.
  end

  if left < 0 
    width = [0, width + left].max
    left = 0
  end

  if top < 0
    height = [0, height + top].max
    top = 0
  end

  return Applitools::Region.new(left, top, width, height)
end
send_key(*args)
Alias for: send_keys
send_keys(*args) click to toggle source
# File lib/eyes_selenium_ruby/eyes/element.rb, line 45
def send_keys(*args)
  current_control = region
  Selenium::WebDriver::Keys.encode(args).each do |key|
    driver.user_inputs << Applitools::TextTrigger.new(key.to_s, current_control)
  end

  web_element.send_keys(args)
end
Also aliased as: send_key