Class: Obxcura::Frame

Inherits:
Object
  • Object
show all
Includes:
DOM, Runtime
Defined in:
lib/obxcura/frame.rb,
lib/obxcura/frame/dom.rb,
lib/obxcura/frame/runtime.rb

Overview

A browsing context inside a Page. It ties together Runtime (executing JS via the Client) and DOM (reads built on that), and reaches the transport through its owning Page — so a Frame never touches the Client directly except via page.client.

Obxcura drives a single main frame per page today (id == the page's target_id); there is deliberately no iframe tree.

Defined Under Namespace

Modules: DOM, Runtime

Constant Summary

Constants included from Runtime

Runtime::EVALUATE_CHUNK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DOM

#at_css, #body, #css, #current_url

Methods included from Runtime

#call_on, #evaluate, #evaluate_func, #read_string

Constructor Details

#initialize(id, page) ⇒ Frame

Returns a new instance of Frame.

Parameters:

  • id (String)

    the frame id (its page's target_id).

  • page (Obxcura::Page)

    the owning page, used to reach the Client.



26
27
28
29
# File 'lib/obxcura/frame.rb', line 26

def initialize(id, page)
  @id = id
  @page = page
end

Instance Attribute Details

#idString

Returns the frame's unique id (the page's CDP target_id).

Returns:

  • (String)

    the frame's unique id (the page's CDP target_id).



19
20
21
# File 'lib/obxcura/frame.rb', line 19

def id
  @id
end

#pageObxcura::Page (readonly)

Returns the page that owns this frame.

Returns:



22
23
24
# File 'lib/obxcura/frame.rb', line 22

def page
  @page
end

Instance Method Details

#titleString

Returns the frame's current document title.

Returns:

  • (String)

    the frame's current document title.



37
38
39
# File 'lib/obxcura/frame.rb', line 37

def title
  evaluate("document.title")
end

#urlString

Returns the frame's current URL.

Returns:

  • (String)

    the frame's current URL.



32
33
34
# File 'lib/obxcura/frame.rb', line 32

def url
  evaluate("window.location.href")
end