Table of Contents

Interface IExecutionContext

Namespace
PuppeteerSharp
Assembly
PuppeteerSharp.dll

The class represents a context for JavaScript execution. Examples of JavaScript contexts are: Each Frame has a separate IExecutionContext All kind of web workers have their own contexts.

public interface IExecutionContext

Properties

Frame

Frame associated with this execution context.

IFrame Frame { get; }

Property Value

IFrame

Remarks

NOTE Not every execution context is associated with a frame. For example, workers and extensions have execution contexts that are not associated with frames.

Methods

EvaluateExpressionAsync(string)

Executes a script in browser context.

Task<JToken> EvaluateExpressionAsync(string script)

Parameters

script string

Script to be evaluated in browser context.

Returns

Task<JToken>

Task which resolves to script return value.

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.

See Also

EvaluateExpressionAsync<T>(string)

Executes a script in browser context.

Task<T> EvaluateExpressionAsync<T>(string script)

Parameters

script string

Script to be evaluated in browser context.

Returns

Task<T>

Task which resolves to script return value.

Type Parameters

T

The type to deserialize the result to.

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.

See Also

EvaluateExpressionHandleAsync(string)

Executes a script in browser context.

Task<IJSHandle> EvaluateExpressionHandleAsync(string script)

Parameters

script string

Script to be evaluated in browser context.

Returns

Task<IJSHandle>

Task which resolves to script return value.

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.

EvaluateFunctionAsync(string, params object[])

Executes a function in browser context.

Task<JToken> EvaluateFunctionAsync(string script, params object[] args)

Parameters

script string

Script to be evaluated in browser context.

args object[]

Arguments to pass to script.

Returns

Task<JToken>

Task which resolves to script return value.

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value. IJSHandle instances can be passed as arguments.

See Also

EvaluateFunctionAsync<T>(string, params object[])

Executes a function in browser context.

Task<T> EvaluateFunctionAsync<T>(string script, params object[] args)

Parameters

script string

Script to be evaluated in browser context.

args object[]

Arguments to pass to script.

Returns

Task<T>

Task which resolves to script return value.

Type Parameters

T

The type to deserialize the result to.

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value. IJSHandle instances can be passed as arguments.

See Also

EvaluateFunctionHandleAsync(string, params object[])

Executes a script in browser context.

Task<IJSHandle> EvaluateFunctionHandleAsync(string pageFunction, params object[] args)

Parameters

pageFunction string

Script to be evaluated in browser context.

args object[]

Function arguments.

Returns

Task<IJSHandle>

Task which resolves to script return value.

Remarks

If the script, returns a Promise, then the method would wait for the promise to resolve and return its value. IJSHandle instances can be passed as arguments.