Class: ElementContext

Inherits:
Object
  • Object
show all
Defined in:
lib/rutl/interface/elements/element_context.rb

Overview

The context passed around to all elements. What they need to know outside of themselves to function.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(destinations: nil, interface: nil, selectors: []) ⇒ ElementContext

Returns a new instance of ElementContext.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rutl/interface/elements/element_context.rb', line 10

def initialize(destinations: nil, interface: nil, selectors: [])
  unless destinations.nil? || destinations.class == Array
    # Should check each destination to make sure it's a Page or a _____, too.
    raise 'destination must be an Array of destinations or nil.'
  end
  @destinations = destinations || []
  unless interface.nil? || interface.class.ancestors.include?(BaseInterface)
    raise "#{interface.class}: #{interface} must be a *Interface class."
  end
  @interface = interface
  @selectors = selectors
end

Instance Attribute Details

#destinationsObject

Returns the value of attribute destinations.



6
7
8
# File 'lib/rutl/interface/elements/element_context.rb', line 6

def destinations
  @destinations
end

#interfaceObject

Returns the value of attribute interface.



7
8
9
# File 'lib/rutl/interface/elements/element_context.rb', line 7

def interface
  @interface
end

#selectorsObject

Returns the value of attribute selectors.



8
9
10
# File 'lib/rutl/interface/elements/element_context.rb', line 8

def selectors
  @selectors
end

Instance Method Details

#find_element(type) ⇒ Object



23
24
25
26
27
28
# File 'lib/rutl/interface/elements/element_context.rb', line 23

def find_element(type)
  # @interface.driver.find_element(type, @selectors[type])
  # Should be this, but apparently @interface.driver is being overwritten
  # (or not written to) and it doesn't work. Using $browser does. :-(
  $browser.interface.driver.find_element(type, @selectors[type])
end