Class: Applitools::Calabash::CalabashElement

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/applitools/calabash/calabash_element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, element_query) ⇒ CalabashElement

Returns a new instance of CalabashElement.

Raises:

  • (Applitools::EyesIllegalArgument)


10
11
12
13
14
# File 'lib/applitools/calabash/calabash_element.rb', line 10

def initialize(element, element_query)
  raise Applitools::EyesIllegalArgument, "Invalid element passed! (#{element})" unless valid_element?(element)
  @original_element = element
  @element_query = element_query
end

Instance Attribute Details

#element_queryObject (readonly)

Returns the value of attribute element_query.



7
8
9
# File 'lib/applitools/calabash/calabash_element.rb', line 7

def element_query
  @element_query
end

#original_elementObject (readonly)

Returns the value of attribute original_element.



7
8
9
# File 'lib/applitools/calabash/calabash_element.rb', line 7

def original_element
  @original_element
end

Instance Method Details

#heightObject



32
33
34
# File 'lib/applitools/calabash/calabash_element.rb', line 32

def height
  self['rect']['height']
end

#leftObject Also known as: x



16
17
18
# File 'lib/applitools/calabash/calabash_element.rb', line 16

def left
  self['rect']['x']
end

#locationObject



36
37
38
# File 'lib/applitools/calabash/calabash_element.rb', line 36

def location
  Applitools::Location.from_struct(self)
end

#regionObject



44
45
46
# File 'lib/applitools/calabash/calabash_element.rb', line 44

def region
  Applitools::Region.from_location_size(location, size)
end

#sizeObject



40
41
42
# File 'lib/applitools/calabash/calabash_element.rb', line 40

def size
  Applitools::RectangleSize.from_struct(self)
end

#to_sObject



48
49
50
# File 'lib/applitools/calabash/calabash_element.rb', line 48

def to_s
  @original_element
end

#topObject Also known as: y



22
23
24
# File 'lib/applitools/calabash/calabash_element.rb', line 22

def top
  self['rect']['y']
end

#widthObject



28
29
30
# File 'lib/applitools/calabash/calabash_element.rb', line 28

def width
  self['rect']['width']
end