Module: Ferrum::Page::Frames

Included in:
Ferrum::Page
Defined in:
lib/ferrum/page/frames.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#main_frameFrame (readonly)

The page’s main frame, the top of the tree and the parent of all frames.

Returns:



11
12
13
# File 'lib/ferrum/page/frames.rb', line 11

def main_frame
  @main_frame
end

Instance Method Details

#frame_by(id: nil, name: nil, execution_id: nil) ⇒ Frame?

Find a frame by given params.

Examples:

page.frame_by(id: "C6D104CE454A025FBCF22B98DE612B12")

Parameters:

  • id (String) (defaults to: nil)

    Unique frame’s id that page provides.

  • name (String) (defaults to: nil)

    Frame’s name if there’s one.

  • execution_id (String) (defaults to: nil)

    Frame’s context execution id.

Returns:

  • (Frame, nil)

    The matching frame.



56
57
58
59
60
61
62
63
64
# File 'lib/ferrum/page/frames.rb', line 56

def frame_by(id: nil, name: nil, execution_id: nil)
  if id
    @frames[id]
  elsif name
    frames.find { |f| f.name == name }
  elsif execution_id
    frames.find { |f| f.execution_id == execution_id }
  end
end

#framesArray<Frame>

Returns all the frames current page have.

Examples:

page.go_to("https://www.w3schools.com/tags/tag_frame.asp")
page.frames # =>
# [
#   #<Ferrum::Frame
#     @id="C6D104CE454A025FBCF22B98DE612B12"
#     @parent_id=nil @name=nil @state=:stopped_loading @execution_id=1>,
#   #<Ferrum::Frame
#     @id="C09C4E4404314AAEAE85928EAC109A93"
#     @parent_id="C6D104CE454A025FBCF22B98DE612B12" @state=:stopped_loading @execution_id=2>,
#   #<Ferrum::Frame
#     @id="2E9C7F476ED09D87A42F2FEE3C6FBC3C"
#     @parent_id="C6D104CE454A025FBCF22B98DE612B12" @state=:stopped_loading @execution_id=3>,
#   ...
# ]

Returns:



34
35
36
# File 'lib/ferrum/page/frames.rb', line 34

def frames
  @frames.values
end

#frames_subscribeObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ferrum/page/frames.rb', line 66

def frames_subscribe
  subscribe_frame_attached
  subscribe_frame_detached
  subscribe_frame_started_loading
  subscribe_frame_navigated
  subscribe_frame_stopped_loading

  subscribe_navigated_within_document

  subscribe_request_will_be_sent

  subscribe_execution_context_created
  subscribe_execution_context_destroyed
  subscribe_execution_contexts_cleared
end