lib/watir/locators/element/selector_builder.rb in watir-6.4.3 vs lib/watir/locators/element/selector_builder.rb in watir-6.5.0

- old
+ new

@@ -1,10 +1,10 @@ module Watir module Locators class Element class SelectorBuilder - VALID_WHATS = [String, Regexp, TrueClass, FalseClass].freeze + VALID_WHATS = [Array, String, Regexp, TrueClass, FalseClass].freeze WILDCARD_ATTRIBUTE = /^(aria|data)_(.+)$/ def initialize(query_scope, selector, valid_attributes) @query_scope = query_scope # either element or browser @selector = selector @@ -33,9 +33,12 @@ when :visible unless what.is_a?(TrueClass) || what.is_a?(FalseClass) raise TypeError, "expected TrueClass or FalseClass, got #{what.inspect}:#{what.class}" end else + if what.is_a?(Array) && how != :class + raise TypeError, "Only :class locator can have a value of an Array" + end unless VALID_WHATS.any? { |t| what.is_a? t } raise TypeError, "expected one of #{VALID_WHATS.inspect}, got #{what.inspect}:#{what.class}" end end end