Skip to content

Target

Namespace: PuppeteerSharp

public abstract class Target : ITarget

Target.

Inheritance: object

Implements: ITarget

Derived: CdpTarget

View source

public abstract ITarget Opener { get; }

Get the target that opened this target.

Value: ITarget

Top-level targets return null.

View source

public abstract TargetType Type { get; }

Gets the type. It will be Type. Can be "page", "background_page", "service_worker", "shared_worker", "browser" or "other".

Value: TargetType — The type.

View source

public abstract string Url { get; }

Gets the URL.

Value: string — The URL.

View source

public abstract Task<IPage> AsPageAsync()

Forcefully creates a page for a target of any type. It is useful if you want to handle a CDP target of type other as a page. If you deal with a regular page target, use PageAsync().

Returns: Task<IPage> — A task that returns a IPage.

View source

public abstract Task<ICDPSession> CreateCDPSessionAsync()

Creates a Chrome Devtools Protocol session attached to the target.

Returns: Task<ICDPSession> — A task that returns a ICDPSession.

View source

public virtual Task<IPage> PageAsync()

Returns the IPage associated with the target. If the target is not "page", "webview" or "background_page" returns null.

Returns: Task<IPage> — a task that returns a IPage.

View source

public virtual Task<WebWorker> WorkerAsync()

If the target is not of type "service_worker" or "shared_worker", returns null.

Returns: Task<WebWorker> — A task that returns a WebWorker.

View source

Made with love by Dario Kondratiuk