ExecutionContext
Namespace: PuppeteerSharp
public sealed class ExecutionContext : IExecutionContext, IDisposable, IAsyncDisposable, IPuppeteerUtilWrapperThe 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.
Inheritance: object
Implements: IExecutionContext, IDisposable, IAsyncDisposable, IPuppeteerUtilWrapper
Properties
Section titled “Properties”EvaluationScriptUrl
Section titled “EvaluationScriptUrl”public static string EvaluationScriptUrl { get; set; }Gets or sets the URL used to identify evaluation scripts. This can be changed to avoid bot detection by services that look for known automation markers.
Value: string
Methods
Section titled “Methods”Dispose()
Section titled “Dispose()”public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
DisposeAsync()
Section titled “DisposeAsync()”public ValueTask DisposeAsync()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
Returns: ValueTask — A task that represents the asynchronous dispose operation.
EvaluateExpressionAsync(string)
Section titled “EvaluateExpressionAsync(string)”public Task<JsonElement?> EvaluateExpressionAsync(string script)Executes a script in browser context.
Parameters
| Name | Type | Description |
|---|---|---|
script |
string | Script to be evaluated in browser context. |
Returns: Task<JsonElement?> — Task which resolves to script return value.
If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.
EvaluateExpressionAsync<T>(string)
Section titled “EvaluateExpressionAsync<T>(string)”public Task<T> EvaluateExpressionAsync<T>(string script)Executes a script in browser context.
Type parameters
| Name | Description |
|---|---|
T |
The type to deserialize the result to. |
Parameters
| Name | Type | Description |
|---|---|---|
script |
string | Script to be evaluated in browser context. |
Returns: Task<T> — Task which resolves to script return value.
If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.
EvaluateExpressionHandleAsync(string)
Section titled “EvaluateExpressionHandleAsync(string)”public Task<IJSHandle> EvaluateExpressionHandleAsync(string script)Executes a script in browser context.
Parameters
| Name | Type | Description |
|---|---|---|
script |
string | Script to be evaluated in browser context. |
Returns: Task<IJSHandle> — Task which resolves to script return value.
If the script, returns a Promise, then the method would wait for the promise to resolve and return its value.
EvaluateFunctionAsync(string, params object[])
Section titled “EvaluateFunctionAsync(string, params object[])”public Task<JsonElement?> EvaluateFunctionAsync(string script, params object[] args)Executes a function in browser context.
Parameters
| Name | Type | Description |
|---|---|---|
script |
string | Script to be evaluated in browser context. |
args |
object[] | Arguments to pass to script. |
Returns: Task<JsonElement?> — Task which resolves to script return value.
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.
EvaluateFunctionAsync<T>(string, params object[])
Section titled “EvaluateFunctionAsync<T>(string, params object[])”public Task<T> EvaluateFunctionAsync<T>(string script, params object[] args)Executes a function in browser context.
Type parameters
| Name | Description |
|---|---|
T |
The type to deserialize the result to. |
Parameters
| Name | Type | Description |
|---|---|---|
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.
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.
EvaluateFunctionHandleAsync(string, params object[])
Section titled “EvaluateFunctionHandleAsync(string, params object[])”public Task<IJSHandle> EvaluateFunctionHandleAsync(string script, params object[] args)Executes a script in browser context.
Parameters
| Name | Type | Description |
|---|---|---|
script |
string | |
args |
object[] | Function arguments. |
Returns: Task<IJSHandle> — Task which resolves to script return value.
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.
GetPuppeteerUtilAsync()
Section titled “GetPuppeteerUtilAsync()”public Task<IJSHandle> GetPuppeteerUtilAsync()Gets the PuppeteerUtil handle.
Returns: Task<IJSHandle> — The PuppeteerUtil handle.
Made with love by Dario Kondratiuk