lib/watir/locators/button/locator.rb in watir-6.14.0 vs lib/watir/locators/button/locator.rb in watir-6.15.0

- old
+ new

@@ -6,24 +6,26 @@ def using_selenium(*) # force watir usage end - def can_convert_regexp_to_contains? - # regexp conversion won't work with the complex xpath selector - false - end + def matches_values?(element, values_to_match) + return super unless values_to_match.key?(:value) - def matches_selector?(element, selector) - if selector.key?(:value) - copy = selector.dup - value = copy.delete(:value) + copy = values_to_match.dup + value = copy.delete(:value) - super(element, copy) && - (fetch_value(element, :value) =~ /#{value}/ || fetch_value(element, :text) =~ /#{value}/) - else - super + everything_except_value = super(element, copy) + + matches_value = fetch_value(element, :value) =~ /#{value}/ + matches_text = fetch_value(element, :text) =~ /#{value}/ + if matches_text + Watir.logger.deprecate(':value locator key for finding button text', + 'use :text locator', + ids: [:value_button]) end + + everything_except_value && (matches_value || matches_text) end end end end end