browsingContext.navigationFailed event

The browsingContext.navigationFailed event of the browsingContext module fires when a cross-document navigation cannot be completed.

Description

In the lifecycle of a failed navigation, this event fires after browsingContext.navigationStarted when the navigation cannot be completed.

Event data

The params field in the event notification is a navigation object with the following fields:

context

A string that contains the ID of the context in which the navigation failed.

A string that contains the UUID that uniquely identifies this navigation. This ID matches the navigation value in the response of the browsingContext.navigate and browsingContext.reload commands.

timestamp

A non-negative integer that represents the time in UTC when the event was fired, as milliseconds elapsed since the epoch.

url

A string that contains the URL being loaded.

userContext Optional

A string that contains the ID of the user context in which the navigation failed.

Examples

Receiving an event when a cross-document navigation fails

Assume you have a WebDriver BiDi connection and an active session with a subscription to browsingContext.navigationFailed.

Suppose you use browsingContext.navigate to load a URL, passing the context ID you obtain from browsingContext.getTree.

The browser first fires a browsingContext.navigationStarted event (that notification is not received since the subscription in this example is only to browsingContext.navigationFailed).

The browser sends the following notification if the navigation cannot be completed, where the context value matches the context ID you passed to browsingContext.navigate:

json
{
  "type": "event",
  "method": "browsingContext.navigationFailed",
  "params": {
    "context": "5e5e96e8-5247-4f22-9b35-a4a2d841cbaa",
    "navigation": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "timestamp": 1712345678901,
    "url": "https://not-a-valid-domain.example"
  }
}

Specifications

Specification
WebDriver BiDi
# event-browsingContext-navigationFailed

Browser compatibility

See also