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)


8
9
10
11
12
# File 'lib/applitools/calabash/calabash_element.rb', line 8

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.



5
6
7
# File 'lib/applitools/calabash/calabash_element.rb', line 5

def element_query
  @element_query
end

#original_elementObject (readonly)

Returns the value of attribute original_element.



5
6
7
# File 'lib/applitools/calabash/calabash_element.rb', line 5

def original_element
  @original_element
end

Instance Method Details

#heightObject



30
31
32
# File 'lib/applitools/calabash/calabash_element.rb', line 30

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

#leftObject Also known as: x



14
15
16
# File 'lib/applitools/calabash/calabash_element.rb', line 14

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

#locationObject



34
35
36
# File 'lib/applitools/calabash/calabash_element.rb', line 34

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

#regionObject



42
43
44
# File 'lib/applitools/calabash/calabash_element.rb', line 42

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

#sizeObject



38
39
40
# File 'lib/applitools/calabash/calabash_element.rb', line 38

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

#to_sObject



46
47
48
# File 'lib/applitools/calabash/calabash_element.rb', line 46

def to_s
  @original_element
end

#topObject Also known as: y



20
21
22
# File 'lib/applitools/calabash/calabash_element.rb', line 20

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

#widthObject



26
27
28
# File 'lib/applitools/calabash/calabash_element.rb', line 26

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