Class: Puppeteer::ExecutionContext

Inherits:
Object
  • Object
show all
Includes:
IfPresent
Defined in:
lib/puppeteer/execution_context.rb

Defined Under Namespace

Classes: EvaluationError, JavaScriptExpression, JavaScriptFunction

Constant Summary collapse

EVALUATION_SCRIPT_URL =
'pprt://__puppeteer_evaluation_script__'
SOURCE_URL_REGEX =
/^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IfPresent

#if_present

Constructor Details

#initialize(client, context_payload, world) ⇒ ExecutionContext

Returns a new instance of ExecutionContext.

Parameters:



11
12
13
14
15
16
# File 'lib/puppeteer/execution_context.rb', line 11

def initialize(client, context_payload, world)
  @client = client
  @world = world
  @context_id = context_payload['id']
  @context_name = context_payload['name']
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



18
19
20
# File 'lib/puppeteer/execution_context.rb', line 18

def client
  @client
end

#worldObject (readonly)

Returns the value of attribute world.



18
19
20
# File 'lib/puppeteer/execution_context.rb', line 18

def world
  @world
end

Instance Method Details

#evaluate(page_function, *args) ⇒ Object

Parameters:

  • page_function (String)

Returns:

  • (Object)


32
33
34
# File 'lib/puppeteer/execution_context.rb', line 32

def evaluate(page_function, *args)
  evaluate_internal(true, page_function, *args)
end

#evaluate_handle(page_function, *args) ⇒ Puppeteer::JSHandle

Parameters:

  • page_function (String)

Returns:



38
39
40
# File 'lib/puppeteer/execution_context.rb', line 38

def evaluate_handle(page_function, *args)
  evaluate_internal(false, page_function, *args)
end