Class: Watir::Frame

Inherits:
Element show all
Includes:
PageContainer
Defined in:
lib/watir/frame.rb,
lib/watir/camel_case.rb

Constant Summary

Constants included from Win32

Win32::FindWindowEx, Win32::GW_CHILD, Win32::GW_ENABLEDPOPUP, Win32::GW_HWNDFIRST, Win32::GW_HWNDLAST, Win32::GW_HWNDNEXT, Win32::GW_HWNDPREV, Win32::GW_MAX, Win32::GW_OWNER, Win32::GetUnknown, Win32::GetWindow, Win32::IsWindow, Win32::User32

Constants inherited from Element

Element::TO_S_SIZE

Instance Attribute Summary

Attributes inherited from Element

#container

Attributes included from Container

#activeObjectHighLightColor, #page_container, #type_keys, #typingspeed

Instance Method Summary collapse

Methods included from PageContainer

#check_for_http_error, #contains_text, #enabled_popup, #html, #set_container, #show_frames, #text, #url

Methods included from Win32

window_exists?

Methods inherited from Element

#<=>, #activeObjectHighLightColor, #after_text, #assert_enabled, #assert_exists, #attribute_value, #before_text, #click, #click!, #enabled?, #exists?, #fire_event, #flash, #focus, #inspect, #method_missing, #ole_object, #ole_object=, #parent, #text, #to_s, #type_keys, #typingspeed, #visible?

Methods included from Container

#area, #areas, #button, #buttons, #cell, #cells, #checkbox, #checkboxes, #dds, #divs, #dls, #dts, #element, #element_by_css, #elements, #ems, #file_field, #file_fields, #form, #forms, #frame, #frames, #hidden, #hiddens, #image, #images, #labels, #link, #links, #lis, #locate_all_elements, #locate_input_element, #locate_tagged_element, #log, #map, #maps, #modal_dialog, #popup, #pres, #ps, #radio, #radios, #row, #rows, #select_list, #select_lists, #set_container, #show_all_objects, #spans, #strongs, #table, #tables, #text_field, #text_fields, #wait

Constructor Details

#initialize(container, how, what) ⇒ Frame

Returns a new instance of Frame.



32
33
34
35
36
37
# File 'lib/watir/frame.rb', line 32

def initialize(container, how, what)
  set_container container
  @how = how
  @what = what
  copy_test_config container
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Watir::Element

Instance Method Details

#attach_commandObject



44
45
46
# File 'lib/watir/frame.rb', line 44

def attach_command
  @container.page_container.attach_command + ".frame(#{@how.inspect}, #{@what.inspect})".gsub('"','\'')
end

#documentObject Also known as: getDocument



39
40
41
42
# File 'lib/watir/frame.rb', line 39

def document
  assert_exists
  @document
end

#locateObject

Find the frame denoted by how and what in the container and return its ole_object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/watir/frame.rb', line 6

def locate
  @o = nil
  if @how == :xpath
    @o = @container.element_by_xpath(@what)
  elsif @how == :css
    @o = @container.element_by_css(@what)
  else      
    locator = FrameLocator.new(@container)
    locator.set_specifier(@how, @what)
    ['FRAME', 'IFRAME'].each do |frame_tag|
      locator.tag = frame_tag
      located_frame, document = locator.locate
      unless (located_frame.nil? && document.nil?)
        @o = located_frame
        @document = document.document
        break
      end
    end
  end
end