Class: Ferrum::Frame

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

Defined Under Namespace

Modules: DOM, Runtime

Constant Summary

Constants included from Runtime

Runtime::DEFAULT_OPTIONS, Runtime::EVALUATE_ASYNC_OPTIONS, Runtime::EXECUTE_OPTIONS, Runtime::INTERMITTENT_ATTEMPTS, Runtime::INTERMITTENT_SLEEP, Runtime::LINK_TAG, Runtime::SCRIPT_SRC_TAG, Runtime::SCRIPT_TEXT_TAG, Runtime::STYLE_TAG

Instance Attribute Summary collapse

Instance Method Summary collapse

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_on, #execute

Constructor Details

#initialize(id, page, parent_id = nil) ⇒ Frame

Returns a new instance of Frame.



14
15
16
# File 'lib/ferrum/frame.rb', line 14

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

Instance Attribute Details

#execution_idObject



42
43
44
45
46
47
48
# File 'lib/ferrum/frame.rb', line 42

def execution_id
  raise NoExecutionContextError unless @execution_id
  @execution_id
rescue NoExecutionContextError
  @page.event.reset
  @page.event.wait(@page.timeout) ? retry : raise
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/ferrum/frame.rb', line 10

def id
  @id
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/ferrum/frame.rb', line 12

def name
  @name
end

#pageObject (readonly)

Returns the value of attribute page.



10
11
12
# File 'lib/ferrum/frame.rb', line 10

def page
  @page
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



10
11
12
# File 'lib/ferrum/frame.rb', line 10

def parent_id
  @parent_id
end

#stateObject

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?(execution_id) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/ferrum/frame.rb', line 38

def execution_id?(execution_id)
  @execution_id == execution_id
end

#inspectObject



50
51
52
# File 'lib/ferrum/frame.rb', line 50

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

Returns:

  • (Boolean)


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

def main?
  @parent_id.nil?
end

#titleObject



30
31
32
# File 'lib/ferrum/frame.rb', line 30

def title
  evaluate("document.title")
end

#urlObject



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

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