lib/watir/locators/element/selector_builder.rb in watir-6.16.5 vs lib/watir/locators/element/selector_builder.rb in watir-6.17.0

- old
+ new

@@ -4,15 +4,14 @@ class SelectorBuilder include Exception attr_reader :custom_attributes, :built WILDCARD_ATTRIBUTE = /^(aria|data)_(.+)$/.freeze - INTEGER_CLASS = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4') ? Fixnum : Integer VALID_WHATS = Hash.new([String, Regexp, TrueClass, FalseClass]).merge(adjacent: [::Symbol], xpath: [String], css: [String], - index: [INTEGER_CLASS], + index: [Integer], visible: [TrueClass, FalseClass], tag_name: [String, Regexp, ::Symbol], visible_text: [String, Regexp], scope: [Hash], text: [String, Regexp]).freeze @@ -51,16 +50,12 @@ @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 - classes.each do |class_name| - next unless class_name.is_a?(String) && class_name.strip.include?(' ') + deprecate_class_array(classes) - deprecate_class_array(class_name) - end - @selector[:class] = classes end if @selector[:adjacent] == :ancestor && @selector.key?(:text) raise LocatorException, 'Can not find parent element with text locator' @@ -81,14 +76,18 @@ scope_invalid_locators = @query_scope.selector_builder.built.keys.reject { |key| key == wd_locator } scope_invalid_locators.empty? end - def deprecate_class_array(class_name) - 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] + 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]) }