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



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

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)


40
41
42
# File 'lib/ferrum/frame.rb', line 40

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

#inspectObject



52
53
54
# File 'lib/ferrum/frame.rb', line 52

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)


36
37
38
# File 'lib/ferrum/frame.rb', line 36

def main?
  @parent_id.nil?
end

#titleObject



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

def title
  evaluate("document.title")
end

#urlObject



28
29
30
# File 'lib/ferrum/frame.rb', line 28

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