Sha256: 762b8aee32fa01309c9fef3f9bceb973786c3a6def4b5f74a48a3b8acb36b30f

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'rutl/null_driver/null_element'

module RUTL
  #
  # This is at a peer level to the webdrivers but it's for a fake brwoser.
  #
  class NullDriver
    attr_accessor :context

    def initialize(context)
      raise 'no context' unless context.is_a?(RUTL::Element::ElementContext)
      @context = context
    end

    # Return a new one of these fake things so that it can be clicked
    # ar written to or whatever.
    def find_element(type, location)
      context = RUTL::Element::ElementContext.new(interface: @context.interface)
      RUTL::Element::NullElement.new(context, type, location)
    end

    # Cheap way to handle browser.navigate.to(url)
    # TODO: Until I care about the url and then I should ????
    def navigate
      context = RUTL::Element::ElementContext.new(interface: @context.interface)
      NullDriver.new(context)
    end

    # Cheap second part to naviate.to(url) calls to look like real drivers.
    def to(url)
      result = @context.interface.find_page(url)
      @context.interface.current_page = result
      result.url
    end

    # Clean out the @@variables from NullElement.
    # Other than this, this is a placeholder to match real drivers.
    def quit
      RUTL::Element::NullElement.clear_variables
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rutl-0.6.0 lib/rutl/null_driver/null_driver.rb
rutl-0.5.0 lib/rutl/null_driver/null_driver.rb
rutl-0.4.0 lib/rutl/null_driver/null_driver.rb