Sha256: 516a614e74fc6a70dba2572e60ea87c7ff3c926948891c13c6a21e08f74618f0
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
require "watir" require "testable/situation" module Testable include Situation module_function def elements @elements = Watir::Container.instance_methods unless @elements end def elements? @elements end def recognizes?(method) @elements.include? method.to_sym end module Element Testable.elements.each do |element| # This is what allows Watir-based elements to be defined # on an element definition. define_method(element) do |*signature| identifier, locator = parse_signature(signature) define_element_accessor(identifier, locator, element) end end private def define_element_accessor(identifier, *locator, element) # This is what allows each identifier to be a method. define_method(identifier.to_s.to_sym) do |*values| no_locator(self.class, identifier) if empty_locator(locator, values) locator = values if locator[0].nil? reference_element(element, locator) end end def parse_signature(signature) [signature.shift, signature.shift] end module Locator private def reference_element(element, locator) @browser.__send__(element, *locator).to_subtype rescue NoMethodError @browser.__send__(element, *locator) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
testable-0.3.0 | lib/testable/element.rb |