lib/watir/locators/element/selector_builder.rb in watir-6.19.1 vs lib/watir/locators/element/selector_builder.rb in watir-7.0.0.beta1
- old
+ new
@@ -23,11 +23,10 @@
end
def build(selector)
@selector = selector
- deprecated_locators
normalize_selector
inspected = selector.inspect
scope = @query_scope unless @selector.key?(:scope) || @query_scope.is_a?(Watir::Browser)
@built = wd_locators.empty? ? build_wd_selector(@selector) : @selector
@@ -43,20 +42,17 @@
end
private
def normalize_selector
+ # TODO: This can be more specific now that only 2
raise LocatorException, "Can not locate element with #{wd_locators}" if wd_locators.size > 1
@selector[:scope] = @query_scope.selector_builder.built if merge_scope?
if @selector.key?(:class) || @selector.key?(:class_name)
- classes = ([@selector[:class]].flatten + [@selector.delete(:class_name)].flatten).compact
-
- deprecate_class_array(classes)
-
- @selector[:class] = classes
+ @selector[:class] = ([@selector[:class]].flatten + [@selector.delete(:class_name)].flatten).compact
end
if @selector[:adjacent] == :ancestor && @selector.key?(:text)
raise LocatorException, 'Can not find parent element with text locator'
end
@@ -76,21 +72,10 @@
scope_invalid_locators = @query_scope.selector_builder.built.keys.reject { |key| key == wd_locator }
scope_invalid_locators.empty?
end
- def deprecate_class_array(class_array)
- class_array.each do |class_name|
- next unless class_name.is_a?(String) && class_name.strip.include?(' ')
-
- dep = "Using the :class locator to locate multiple classes with a String value (i.e. \"#{class_name}\")"
- Watir.logger.deprecate dep,
- "Array (e.g. #{class_name.split})",
- ids: [:class_array]
- end
- end
-
def check_type(how, what)
if %i[class class_name].include? how
[what].flatten.each { |value| raise_unless(value, VALID_WHATS[how]) }
else
raise_unless(what, VALID_WHATS[how])
@@ -112,24 +97,16 @@
when :text, :xpath, :index, :css, :visible, :visible_text, :adjacent
[how, what]
when :class
what = false if what.tap { |arr| arr.delete('') }.empty?
[how, what]
- when :link
- [:link_text, what]
when :label, :visible_label
if should_use_label_element?
["#{how}_element".to_sym, what]
else
[how, what]
end
- when :caption
- # This allows any element to be located with 'caption' instead of 'text'
- # It is deprecated because caption is a valid attribute on a Table
- # It is also a valid Element, so it also needs to be removed from the Table attributes list
- Watir.logger.deprecate('Locating elements with :caption', ':text locator', ids: [:caption])
- [:text, what]
else
check_custom_attribute how
[how, what]
end
end
@@ -171,21 +148,9 @@
def raise_unless(what, types)
return if types.include?(what.class)
raise TypeError, "expected one of #{types}, got #{what.inspect}:#{what.class}"
- end
-
- def deprecated_locators
- %i[partial_link_text link_text link].each do |locator|
- next unless @selector.key?(locator)
-
- Watir.logger.deprecate(":#{locator} locator", ':visible_text', ids: [:link_text])
- tag = @selector[:tag_name]
- next if tag.nil? || tag == 'a'
-
- raise LocatorException, "Can not use #{locator} locator to find a #{tag} element"
- end
end
end
end
end
end