Class: Kookaburra::UIDriver::ScopedBrowser

Inherits:
BasicObject
Defined in:
lib/kookaburra/ui_driver/scoped_browser.rb

Overview

Wraps a Kookaburra browser object and changes all method calls to that object so that they are scoped within the specified #component_locator.

Instance Method Summary collapse

Constructor Details

#initialize(browser, component_locator) ⇒ ScopedBrowser

Returns a new instance of ScopedBrowser.

Parameters:

  • browser (Object)

    The browser driver object used by Kookaburra to drive the browser session

  • component_locator (Proc)

    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 Kookaburra::UIDriver::ScopedBrowser will not know the correct string at the time this object is created.)



16
17
18
19
# File 'lib/kookaburra/ui_driver/scoped_browser.rb', line 16

def initialize(browser, component_locator)
  @browser = browser
  @component_locator = component_locator
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object (private)



27
28
29
30
31
# File 'lib/kookaburra/ui_driver/scoped_browser.rb', line 27

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