Table of Contents

Class Target

Namespace
PuppeteerSharp
Assembly
PuppeteerSharp.dll

Target.

public abstract class Target : ITarget
Inheritance
Target
Implements
Derived

Properties

Opener

Get the target that opened this target.

public abstract ITarget Opener { get; }

Property Value

ITarget

Remarks

Top-level targets return null.

TargetId

Gets the target identifier.

public string TargetId { get; }

Property Value

string

The target identifier.

Type

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

public virtual TargetType Type { get; }

Property Value

TargetType

The type.

Url

Gets the URL.

public string Url { get; }

Property Value

string

The URL.

Methods

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().

public abstract Task<IPage> AsPageAsync()

Returns

Task<IPage>

A task that returns a IPage.

CreateCDPSessionAsync()

Creates a Chrome Devtools Protocol session attached to the target.

public abstract Task<ICDPSession> CreateCDPSessionAsync()

Returns

Task<ICDPSession>

A task that returns a ICDPSession.

PageAsync()

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

public virtual Task<IPage> PageAsync()

Returns

Task<IPage>

a task that returns a IPage.

WorkerAsync()

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

public virtual Task<WebWorker> WorkerAsync()

Returns

Task<WebWorker>

A task that returns a WebWorker.