Class: Watir::FrameLocator

Inherits:
TaggedElementLocator show all
Defined in:
lib/watir/locator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TaggedElementLocator

#match?, #set_specifier

Methods inherited from Locator

#match_with_specifiers?, #normalize_specifiers!

Methods included from Watir

_register, _unregister, autoit, #dialog, until_with_timeout

Constructor Details

#initialize(container) ⇒ FrameLocator

Returns a new instance of FrameLocator.



90
91
92
# File 'lib/watir/locator.rb', line 90

def initialize(container)
  @container = container
end

Instance Attribute Details

#tagObject

Returns the value of attribute tag.



88
89
90
# File 'lib/watir/locator.rb', line 88

def tag
  @tag
end

Instance Method Details

#each_element(tag) ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/watir/locator.rb', line 94

def each_element tag
  frames = @container.document.frames
  i = 0
  @container.document.getElementsByTagName(tag).each do |frame|
    element = Element.new(frame)
    document = frames.item(i)
    yield element, document
    i += 1
  end
end

#locateObject



105
106
107
108
109
110
111
112
113
# File 'lib/watir/locator.rb', line 105

def locate
  count = 0
  each_element(@tag) do |element, document|
    next unless match_with_specifiers?(element)
    count += 1
    return element.ole_object, document if count == @specifiers[:index]
  end # elements
  nil
end