lib/watir-webdriver/elements/frame.rb in watir-webdriver-0.2.2 vs lib/watir-webdriver/elements/frame.rb in watir-webdriver-0.2.3
- old
+ new
@@ -10,17 +10,15 @@
FramedDriver.new(element, driver)
end
def assert_exists
- if element = @selector[:element]
- @parent.assert_exists
- @element = FramedDriver.new(element, driver)
- else
- @element = nil
+ if @selector.has_key? :element
+ raise UnknownFrameException, "wrapping a WebDriver element as a Frame is not currently supported"
end
+ @element = nil # we need to re-locate every time
super
end
def execute_script(*args)
browser.execute_script(*args)
@@ -37,11 +35,11 @@
end
private
def locate_iframe
- # hack - frame doesn't have IFrame's attributes either
+ # hack - Frame doesn't have IFrame's attributes either
IFrame.new(@parent, @selector.merge(:tag_name => "iframe")).locate
end
def locate_frame
locator = locator_class.new(@parent.wd, @selector.merge(:tag_name => "frame"), self.class.attribute_list)
@@ -54,9 +52,15 @@
Frame.new(self, extract_selector(args))
end
def frames(*args)
FrameCollection.new(self, extract_selector(args).merge(:tag_name => /^(iframe|frame)$/)) # hack
+ end
+ end
+
+ class FrameCollection < ElementCollection
+ def to_a
+ (0...elements.size).map { |idx| element_class.new @parent, :index => idx }
end
end
# @api private
#