Class: Watir::Frame

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

Constant Summary collapse

TAG =
['FRAME', 'IFRAME']

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 collapse

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!, #create_event, #dispatch_event, #enabled?, #exists?, #fire_event, #flash, #focus, inherited, #inspect, #method_missing, #name, #ole_object, #ole_object=, #parent, #text, #to_s, #type_keys, #typingspeed, #visible?

Methods included from Container

#input_element_locator, #locator_for, #log, #set_container, #show_all_objects, #tagged_element_locator, #wait

Constructor Details

#initialize(container, how, what) ⇒ Frame

Returns a new instance of Frame.



27
28
29
30
31
32
# File 'lib/watir/frame.rb', line 27

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 Attribute Details

#documentObject Also known as: getDocument

Returns the value of attribute document.



6
7
8
# File 'lib/watir/frame.rb', line 6

def document
  @document
end

Instance Method Details

#__ole_inner_elementsObject



23
24
25
# File 'lib/watir/frame.rb', line 23

def __ole_inner_elements
  document.body.all
end

#attach_commandObject



47
48
49
# File 'lib/watir/frame.rb', line 47

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

#document_modeObject



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

def document_mode
  document.documentMode
end

#locateObject

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



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/watir/frame.rb', line 9

def locate
  frame, document = @container.locator_for(FrameLocator, @how, @what).locate
  if frame && document
    @o = frame
    begin
      @document = document.document
    rescue WIN32OLERuntimeError => e
      # This frame's content is not directly accessible but let the
      # user continue so they can access the frame properties            
      raise e unless e.message =~ /Access is denied/
    end        
  end
end