Target methods, browser sessions serve 5, phone sessions 0 and computer sessions 5. A method marked not served answers StrategyUnavailable on that kind of session; check the handshake’s capabilities before relying on one.
Target.getTargets
Browser: served
Phone: not served
Computer: served
The open tabs, in the order they were opened, oldest first (as Playwright’s context.pages()); not the tab strip’s visual order. A tab reopened as about:blank after the last one closed counts as newly opened. active is the tab in front; current is the one target-scoped calls without a targetId go to. They differ when a page brings a popup forward.
| Field | Type | Description |
|---|---|---|
targets | TargetInfo[] |
Target.createTarget
Browser: served
Phone: not served
Computer: served
Open a tab at url (about:blank when omitted). The new tab comes to the front but does not become current; pass its targetId, or activate it. url follows Page.navigate’s scheme rule.
| Param | Type | Required | Description |
|---|---|---|---|
url | string | No | Omitted opens about:blank. |
idempotencyKey | string | No | Makes a re-send after a reconnect safe: a repeated key returns the recorded response without acting again. See Idempotency keys. |
| Field | Type | Description |
|---|---|---|
targetId | string | Opaque tab id, stable while the tab is open. Never parse it. |
Target.closeTarget
Browser: served
Phone: not served
Computer: served
Close a tab. Closing the current target leaves none: target-scoped calls without a targetId fail with TargetNotFound until Target.activateTarget, even when the last tab closed and about:blank was opened in its place.
| Param | Type | Required | Description |
|---|---|---|---|
targetId | string | Yes | Opaque tab id, stable while the tab is open. Never parse it. |
idempotencyKey | string | No | Makes a re-send after a reconnect safe: a repeated key returns the recorded response without acting again. See Idempotency keys. |
{}.
Target.activateTarget
Browser: served
Phone: not served
Computer: served
Bring a tab to the front and make it the current target.
| Param | Type | Required | Description |
|---|---|---|---|
targetId | string | Yes | Opaque tab id, stable while the tab is open. Never parse it. |
idempotencyKey | string | No | Makes a re-send after a reconnect safe: a repeated key returns the recorded response without acting again. See Idempotency keys. |
{}.
Target.waitForTarget
Browser: served
Phone: not served
Computer: served
Wait for a tab matching openerId and urlContains, such as a popup or a target=_blank link. With afterSeq, only tabs opened after that event-log position count; without it, an already open match answers at once. Fails with EventsExpired when afterSeq is older than the log keeps, and ActionTimeout when timeoutMs runs out.
| Param | Type | Required | Description |
|---|---|---|---|
openerId | string | No | Opaque tab id, stable while the tab is open. Never parse it. |
urlContains | string | No | A substring the tab’s URL must contain. |
afterSeq | integer | No | Only events after this event-log position count (a response’s seq). The log keeps each category for its own window (events: 1000 entries or 5 minutes; network records: 5000 entries or 2 minutes). One older than the window of the category the wait reads fails with EventsExpired; re-read state instead. |
timeoutMs | integer | No | Budget in milliseconds. 0 or omitted means 30000; at most 120000. Running out is ActionTimeout. |
| Field | Type | Description |
|---|---|---|
targetId | string | Opaque tab id, stable while the tab is open. Never parse it. |
url | string | |
title | string | |
active | boolean | The tab is in front. |
current | boolean | Target-scoped calls without a targetId go to this tab. |
openerId | string | The tab whose page opened this one, for popups and target=_blank links. |