Module: Watir::Locators::ClassHelpers

Included in:
Element, ElementCollection
Defined in:
lib/watir/locators.rb

Instance Method Summary collapse

Instance Method Details

#class_from_string(string) ⇒ Object


57
58
59
60
61
# File 'lib/watir/locators.rb', line 57

def class_from_string(string)
  Kernel.const_get(string)
rescue NameError
  nil
end

#element_class_nameObject


63
64
65
# File 'lib/watir/locators.rb', line 63

def element_class_name
  element_class.to_s.split('::').last
end

#element_matcher_classObject


43
44
45
46
47
48
# File 'lib/watir/locators.rb', line 43

def element_matcher_class
  class_from_string("#{browser.locator_namespace}::#{element_class_name}::Matcher") ||
    class_from_string("Watir::Locators::#{element_class_name}::Matcher") ||
    class_from_string("#{browser.locator_namespace}::Element::Matcher") ||
    Locators::Element::Matcher
end

#locatorObject


71
72
73
74
# File 'lib/watir/locators.rb', line 71

def locator
  @element_matcher ||= element_matcher_class.new(@query_scope, @selector.dup)
  @locator ||= locator_class.new(@element_matcher)
end

#locator_classObject


36
37
38
39
40
41
# File 'lib/watir/locators.rb', line 36

def locator_class
  class_from_string("#{browser.locator_namespace}::#{element_class_name}::Locator") ||
    class_from_string("Watir::Locators::#{element_class_name}::Locator") ||
    class_from_string("#{browser.locator_namespace}::Element::Locator") ||
    Locators::Element::Locator
end

#selector_builderObject


67
68
69
# File 'lib/watir/locators.rb', line 67

def selector_builder
  @selector_builder ||= selector_builder_class.new(element_class.attribute_list, @query_scope)
end

#selector_builder_classObject


50
51
52
53
54
55
# File 'lib/watir/locators.rb', line 50

def selector_builder_class
  class_from_string("#{browser.locator_namespace}::#{element_class_name}::SelectorBuilder") ||
    class_from_string("Watir::Locators::#{element_class_name}::SelectorBuilder") ||
    class_from_string("#{browser.locator_namespace}::Element::SelectorBuilder") ||
    Locators::Element::SelectorBuilder
end