Class: Celerity::Frame

Included Modules

Celerity::Container

Attributes

Instance Attributes

page [RW] public

Sets the attribute page.

Constants

ATTRIBUTES
BASE_ATTRIBUTES | [:longdesc, :name, :src, :frameborder, :marginwidth, :marginheight, :noresize, :scrolling]
DEFAULT_HOW
:name
TAGS
[Identifier.new('frame'), Identifier.new('iframe')]

Constructor Summary

This class inherits a constructor from Celerity::Element.

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

public method_missing(meth, *args, &blk)
[View source]


63
64
65
66
67
68
69
70
71
72
# File 'lib/celerity/elements/frame.rb', line 63

def method_missing(meth, *args, &blk)
  meth = selector_to_attribute(meth)
  if self.class::ATTRIBUTES.include?(meth)
    assert_exists
    @inline_frame_object.getAttribute(meth.to_s)
  else
    Log.warn "Element\#method_missing calling super with #{meth.inspect}"
    super
  end
end

Public Visibility

Public Instance Method Summary

#assert_exists

Override assert_exists to raise UnknownFrameException (for Watir compatibility).

#execute_script(source)

Executes the given JavaScript string in this frame.

#locate

Override the default locate to handle frame and inline frames.

#to_s
#update_page(value)

Updates the brwoser page with the page from this frame’s top window.

Public Instance Method Details

assert_exists

public assert_exists

Override assert_exists to raise UnknownFrameException (for Watir compatibility)

Meta Tags

Parameters:

[View source]


31
32
33
34
35
36
# File 'lib/celerity/elements/frame.rb', line 31

def assert_exists
  locate
  unless @object
    raise UnknownFrameException, "unable to locate frame, using #{identifier_string}"
  end
end

execute_script

public execute_script(source)

Executes the given JavaScript string in this frame. (Celerity only)

[View source]


42
43
44
45
# File 'lib/celerity/elements/frame.rb', line 42

def execute_script(source)
  assert_exists
  @page.executeJavaScript(source.to_s).getJavaScriptResult
end

locate

public locate

Override the default locate to handle frame and inline frames.

Meta Tags

Parameters:

[View source]


15
16
17
18
19
20
21
22
23
24
# File 'lib/celerity/elements/frame.rb', line 15

def locate
  super
  if @object
    @inline_frame_object = @object.getEnclosedWindow.getFrameElement
    self.page            = @object.getEnclosedPage
    if (frame = self.page.getDocumentElement)
      @object = frame
    end
  end
end

to_s

public to_s
[View source]


58
59
60
61
# File 'lib/celerity/elements/frame.rb', line 58

def to_s
  assert_exists
  create_string(@inline_frame_object)
end

update_page

public update_page(value)

Updates the brwoser page with the page from this frame’s top window. Used internally.

Meta Tags

Parameters:

[View source]


54
55
56
# File 'lib/celerity/elements/frame.rb', line 54

def update_page(value)
  @browser.page = value.getEnclosingWindow.getTopWindow.getEnclosedPage
end