Sha256: ea2cfb4e89356594b771c0fae92583e17574443fab383b3507d588bd2b95337f

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

module RUTL
  module Element
  #
  # The context passed around to all elements.
  # What they need to know outside of themselves to function.
  #
  class ElementContext
    # Nil. Or an Array. One would hope an Array of states. But I'm not checking.
    attr_accessor :destinations
    # Nil. Or a RUTL::BaseInterface.
    attr_accessor :interface
    # An Arrray, maybe empty and maybe an array of selectors.
    # TODO: This should be a hash.
    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.is_a?(RUTL::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
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rutl-0.5.0 lib/rutl/element/element_context.rb