lib/rutl/interface/elements/base_element.rb in rutl-0.1.3 vs lib/rutl/interface/elements/base_element.rb in rutl-0.1.4
- old
+ new
@@ -1,28 +1,24 @@
#
# Page elements. Base class.
#
class BaseElement
- attr_accessor :interface
- def driver
- @interface.driver
- end
- attr_accessor :selectors
- attr_accessor :destinations
+ attr_accessor :context
- def initialize(selectors = {}, destinations = [])
- @selectors = selectors
- @destinations = destinations
+ def initialize(element_context)
+ raise element_context.to_s unless element_context.is_a? ElementContext
+ @context = element_context
+ # Not sure why, but I'm seeing Chrome fail becase the context interface
+ # passed in isn't the same as the browser's interface.
+ # This only happens with click test cases, before the click, and
+ # only if that case isn't run first.
+ # The context we're passed is also an instance from as ChromeInterface,
+ # but a different instance.
+ #
+ # Here's the kludge workaround line:
+ @context.interface = $browser.interface
end
- def find_css(selectors)
- result = driver.find_element(:css, selectors[:css])
- return result unless NullDriver == result.class
- result.destinations = @destinations
- result.interface = @interface
- result
- end
-
def this_css
- find_css(@selectors)
+ @context.find_element(:css)
end
end