Table of Contents

Interface ITarget

Namespace
PuppeteerSharp
Assembly
PuppeteerSharp.dll

Target.

public interface ITarget

Properties

Browser

Get the browser the target belongs to.

IBrowser Browser { get; }

Property Value

IBrowser

BrowserContext

Get the browser context the target belongs to.

IBrowserContext BrowserContext { get; }

Property Value

IBrowserContext

Opener

Get the target that opened this target.

ITarget Opener { get; }

Property Value

ITarget

Remarks

Top-level targets return null.

TargetId

Gets the target identifier.

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".

TargetType Type { get; }

Property Value

TargetType

The type.

Url

Gets the URL.

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

Task<IPage> AsPageAsync()

Returns

Task<IPage>

A task that returns a IPage.

CreateCDPSessionAsync()

Creates a Chrome Devtools Protocol session attached to the target.

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.

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.

Task<WebWorker> WorkerAsync()

Returns

Task<WebWorker>

A task that returns a WebWorker.