Sha256: fd461ca694deb2fa12b6cf4c79b3182f38f546b59fb581acc9a6a6bc573ed5a5

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

#
# The context passed around to all elements.
# What they need to know outside of themselves to function.
#
class ElementContext
  attr_accessor :destinations
  attr_accessor :interface
  attr_accessor :selectors

  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

  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rutl-0.3.0 lib/rutl/interface/elements/element_context.rb
rutl-0.2.1 lib/rutl/interface/elements/element_context.rb
rutl-0.2.0 lib/rutl/interface/elements/element_context.rb
rutl-0.1.4 lib/rutl/interface/elements/element_context.rb