Class: Watigiri::Locators::TextField::Locator

Inherits:
Watir::Locators::TextField::Locator
  • Object
show all
Includes:
LocatorHelpers
Defined in:
lib/watigiri/locators/element/locator.rb

Instance Method Summary collapse

Methods included from LocatorHelpers

#fetch_value, #locate, #locate_all, #locate_element, #locate_elements, #noko_element, #nokogiri_to_selenium, #set_nokogiri, #text_regexp_deprecation

Instance Method Details

#matches_selector?(element, rx_selector) ⇒ Boolean

Returns:

  • (Boolean)


165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/watigiri/locators/element/locator.rb', line 165

def matches_selector?(element, rx_selector)
  return super if element.is_a? Selenium::WebDriver::Element
  rx_selector = rx_selector.dup

  tag_name = element.tag_name

  %i[text value label].each do |key|
    next unless rx_selector.key?(key)
    correct_key = tag_name == 'input' ? :value : :text
    rx_selector[correct_key] = rx_selector.delete(key)
  end

  rx_selector.all? do |how, what|
    val = fetch_value(element, how)
    what == val || val =~ /#{what}/
  end
end

#regex?Boolean

Returns:

  • (Boolean)


183
184
185
186
187
188
# File 'lib/watigiri/locators/element/locator.rb', line 183

def regex?
  return @regex unless @regex.nil?

  return false unless (@selector.keys & %i[adjacent visible label text visible_text visible_label]).empty?
  @regex = @selector.any? { |k, v| v.is_a?(Regexp) && k != :value }
end