Interface IWorker
- Namespace
- Microsoft.Playwright
- Assembly
- Microsoft.Playwright.dll
The Worker class represents a WebWorker.
worker
event is emitted on the page object to signal a worker creation. close
event is emitted on the worker object when the worker is gone.
page.Worker += (_, worker) =>
{
Console.WriteLine($"Worker created: {worker.Url}");
worker.Close += (_, _) => Console.WriteLine($"Worker closed {worker.Url}");
};
Console.WriteLine("Current Workers:");
foreach(var pageWorker in page.Workers)
{
Console.WriteLine($"\tWorker: {pageWorker.Url}");
}
public interface IWorker
Properties
Url
string Url { get; }
Property Value
Methods
EvaluateAsync<T>(string, object?)
Returns the return value of expression
.
If the function passed to the EvaluateAsync<T>(string, object?) returns a Task, then EvaluateAsync<T>(string, object?) would wait for the promise to resolve and return its value.
If the function passed to the EvaluateAsync<T>(string, object?) returns a non-undefined
.
Playwright also supports transferring some additional values that are not serializable
by JSON
: -0
, NaN
, Infinity
, -Infinity
.
Task<T> EvaluateAsync<T>(string expression, object? arg = null)
Parameters
expression
stringJavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.
arg
objectOptional argument to pass to
expression
.
Returns
- Task<T>
Type Parameters
T
EvaluateHandleAsync(string, object?)
Returns the return value of expression
as a IJSHandle.
The only difference between EvaluateAsync<T>(string, object?) and EvaluateHandleAsync(string, object?) is that EvaluateHandleAsync(string, object?) returns IJSHandle.
If the function passed to the EvaluateHandleAsync(string, object?) returns a Task, then EvaluateHandleAsync(string, object?) would wait for the promise to resolve and return its value.
Task<IJSHandle> EvaluateHandleAsync(string expression, object? arg = null)
Parameters
expression
stringJavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.
arg
objectOptional argument to pass to
expression
.
Returns
Events
Close
Emitted when this dedicated WebWorker is terminated.
event EventHandler<IWorker> Close