Class: Ferrum::Frame
- Inherits:
-
Object
- Object
- Ferrum::Frame
- Defined in:
- lib/ferrum/frame.rb,
lib/ferrum/frame/dom.rb,
lib/ferrum/frame/runtime.rb
Defined Under Namespace
Constant Summary
Constants included from Runtime
Runtime::INTERMITTENT_ATTEMPTS, Runtime::INTERMITTENT_SLEEP, Runtime::LINK_TAG, Runtime::SCRIPT_SRC_TAG, Runtime::SCRIPT_TEXT_TAG, Runtime::STYLE_TAG
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #execution_id ⇒ Object
- #execution_id?(execution_id) ⇒ Boolean
-
#initialize(id, page, parent_id = nil) ⇒ Frame
constructor
A new instance of Frame.
- #inspect ⇒ Object
- #main? ⇒ Boolean
- #reset_execution_id ⇒ Object
- #set_content(html) ⇒ Object
- #set_execution_id(value) ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
Methods included from DOM
#at_css, #at_xpath, #body, #css, #current_title, #current_url, #doctype, #xpath
Methods included from Runtime
#add_script_tag, #add_style_tag, #evaluate, #evaluate_async, #evaluate_func, #evaluate_on, #execute
Constructor Details
#initialize(id, page, parent_id = nil) ⇒ Frame
Returns a new instance of Frame.
13 14 15 16 |
# File 'lib/ferrum/frame.rb', line 13 def initialize(id, page, parent_id = nil) @execution_id = nil @id, @page, @parent_id = id, page, parent_id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/ferrum/frame.rb', line 11 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/ferrum/frame.rb', line 11 def name @name end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
10 11 12 |
# File 'lib/ferrum/frame.rb', line 10 def page @page end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
10 11 12 |
# File 'lib/ferrum/frame.rb', line 10 def parent_id @parent_id end |
#state ⇒ Object
Returns the value of attribute state.
10 11 12 |
# File 'lib/ferrum/frame.rb', line 10 def state @state end |
Instance Method Details
#execution_id ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/ferrum/frame.rb', line 51 def execution_id raise NoExecutionContextError unless @execution_id @execution_id rescue NoExecutionContextError @page.event.reset @page.event.wait(@page.timeout) ? retry : raise end |
#execution_id?(execution_id) ⇒ Boolean
47 48 49 |
# File 'lib/ferrum/frame.rb', line 47 def execution_id?(execution_id) @execution_id == execution_id end |
#inspect ⇒ Object
67 68 69 |
# File 'lib/ferrum/frame.rb', line 67 def inspect %(#<#{self.class} @id=#{@id.inspect} @parent_id=#{@parent_id.inspect} @name=#{@name.inspect} @state=#{@state.inspect} @execution_id=#{@execution_id.inspect}>) end |
#main? ⇒ Boolean
34 35 36 |
# File 'lib/ferrum/frame.rb', line 34 def main? @parent_id.nil? end |
#reset_execution_id ⇒ Object
63 64 65 |
# File 'lib/ferrum/frame.rb', line 63 def reset_execution_id @execution_id = nil end |
#set_content(html) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/ferrum/frame.rb', line 38 def set_content(html) evaluate_async(%( document.open(); document.write(arguments[0]); document.close(); arguments[1](true); ), @page.timeout, html) end |
#set_execution_id(value) ⇒ Object
59 60 61 |
# File 'lib/ferrum/frame.rb', line 59 def set_execution_id(value) @execution_id ||= value end |
#title ⇒ Object
30 31 32 |
# File 'lib/ferrum/frame.rb', line 30 def title evaluate("document.title") end |
#url ⇒ Object
26 27 28 |
# File 'lib/ferrum/frame.rb', line 26 def url evaluate("document.location.href") end |