lib/watir/locators/element/selector_builder.rb in watir-6.0.0.beta3 vs lib/watir/locators/element/selector_builder.rb in watir-6.0.0.beta4
- old
+ new
@@ -1,17 +1,14 @@
-require 'watir/locators/element/selector_builder/css'
-require 'watir/locators/element/selector_builder/xpath'
-
module Watir
module Locators
class Element
class SelectorBuilder
VALID_WHATS = [String, Regexp]
WILDCARD_ATTRIBUTE = /^(aria|data)_(.+)$/
- def initialize(parent, selector, valid_attributes)
- @parent = parent # either element or browser
+ def initialize(query_scope, selector, valid_attributes)
+ @query_scope = query_scope # either element or browser
@selector = selector
@valid_attributes = valid_attributes
end
def normalized_selector
@@ -96,13 +93,12 @@
[how, what]
end
def build_wd_selector(selectors)
- unless selectors.values.any? { |e| e.is_a? Regexp }
- build_css(selectors) || build_xpath(selectors)
- end
+ return if selectors.values.any? { |e| e.is_a? Regexp }
+ build_xpath(selectors)
end
def valid_attribute?(attribute)
@valid_attributes && @valid_attributes.include?(attribute)
end
@@ -120,28 +116,15 @@
def build_xpath(selectors)
xpath_builder.build(selectors)
end
- def build_css(selectors)
- css_builder.build(selectors)
- end
-
def xpath_builder_class
Kernel.const_get("#{self.class.name}::XPath")
rescue
XPath
end
- def css_builder
- @css_builder ||= css_builder_class.new
- end
-
- def css_builder_class
- Kernel.const_get("#{self.class.name}::CSS")
- rescue
- CSS
- end
end
end
end
end