Sha256: 82ae7adee1ebee49f8ed899c73966ed4eafc4d6893ca966817b2234420b62fe0

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

class Kookaburra
  class UIDriver
    # Wraps a Kookaburra `browser` object and changes all method calls
    # to that object so that they are scoped within the specified
    # {#component_locator}.
    class ScopedBrowser < BasicObject

      # @param [Object] browser The browser driver object used by
      #   Kookaburra to drive the browser session
      # @param [Proc] component_locator A Proc that will return the CSS
      #   locator used to identify the HTML element within which all
      #   calls to this object should be scoped. (A Proc is used rather
      #   than a string, because it is possible that the object creating
      #   this {ScopedBrowser} will not know the correct string at the
      #   time this object is created.)
      def initialize(browser, component_locator)
        @browser = browser
        @component_locator = component_locator
      end

      private

      def component_locator
        @component_locator.call
      end

      def method_missing(name, *args, &blk)
        @browser.within(component_locator) do
          @browser.send(name, *args, &blk)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kookaburra-3.0.1 lib/kookaburra/ui_driver/scoped_browser.rb
kookaburra-3.0.0 lib/kookaburra/ui_driver/scoped_browser.rb
kookaburra-2.0.0 lib/kookaburra/ui_driver/scoped_browser.rb
kookaburra-1.3.1 lib/kookaburra/ui_driver/scoped_browser.rb
kookaburra-1.3.0 lib/kookaburra/ui_driver/scoped_browser.rb
kookaburra-1.2.3 lib/kookaburra/ui_driver/scoped_browser.rb
kookaburra-1.2.2 lib/kookaburra/ui_driver/scoped_browser.rb
kookaburra-1.2.1 lib/kookaburra/ui_driver/scoped_browser.rb
kookaburra-1.2.0 lib/kookaburra/ui_driver/scoped_browser.rb