Class: Watir::InputElementLocator

Inherits:
Locator
  • Object
show all
Defined in:
lib/watir/locator.rb

Instance Method Summary collapse

Methods inherited from Locator

#create_element, #document, #has_excluding_specifiers?, #locate_by_id, #locate_by_xpath_css_ole, #match_with_specifiers?, #normalize_specifiers!, #set_specifier

Methods included from Watir

until_with_timeout

Constructor Details

#initialize(container, types, klass) ⇒ InputElementLocator

Returns a new instance of InputElementLocator.



193
194
195
196
197
# File 'lib/watir/locator.rb', line 193

def initialize container, types, klass
  @container = container
  @types = types
  @klass = klass || Element
end

Instance Method Details

#eachObject



219
220
221
222
223
224
225
# File 'lib/watir/locator.rb', line 219

def each
  each_element do |element| 
    next unless @types.include?(element.type) && match_with_specifiers?(element)
    yield element
  end 
  nil
end

#each_elementObject



199
200
201
202
203
204
205
# File 'lib/watir/locator.rb', line 199

def each_element
  elements = locate_by_name || @container.__ole_inner_elements
  elements.each do |object|
    yield create_element object
  end
  nil
end

#locateObject



207
208
209
210
211
212
213
214
215
216
217
# File 'lib/watir/locator.rb', line 207

def locate
  el = locate_by_id
  return el if el
  return locate_by_xpath_css_ole if has_excluding_specifiers?

  count = Watir::IE.base_index - 1
  each do |element|
    count += 1
    return element.ole_object if count == @specifiers[:index]
  end
end

#match?(element, how, what) ⇒ Boolean

return true if the element matches the provided how and what

Returns:

  • (Boolean)


228
229
230
231
232
233
234
235
236
237
# File 'lib/watir/locator.rb', line 228

def match? element, how, what
  begin
    attribute = element.send(how)
  rescue NoMethodError
    raise MissingWayOfFindingObjectException,
      "#{how} is an unknown way of finding an <INPUT> element (#{what})"
  end

  what.matches(attribute)
end