lib/page-object/accessors.rb in page-object-0.2.1 vs lib/page-object/accessors.rb in page-object-0.2.2

- old
+ new

@@ -18,9 +18,32 @@ def page_url(url) define_method("goto") do platform.navigate_to url end end + + # + # Identify an element as existing within a frame or iframe. A frame parameter + # is passed to the block and must be passed to the other calls to PageObject. + # You can nest calls to in_frame by passing the frame to the next level. + # + # @example + # in_frame(:id => 'frame_id') do |frame| + # text_field(:first_name, :id => 'fname', :frame => frame) + # end + # + # @param [Hash] identifier how we find the frame. The valid keys are: + # * :id => Watir and Selenium + # * :index => Watir and Selenium + # * :name => Watir and Selenium + # @param frame passed from a previous call to in_frame. Used to nest calls + # @param block that contains the calls to elements that exist inside the frame. + # + def in_frame(identifier, frame=nil, &block) + frame = [] if frame.nil? + frame << identifier + block.call(frame) + end # # adds three methods to the page object - one to set text in a text field, # another to retrieve text from a text field and another to return the text # field element.