browsingContext.traverseHistory commandThe browsingContext.traverseHistory command of the browsingContext module navigates back or forward in the session history of the specified top-level context, similar to a user clicking the browser's back and forward buttons.
{
"method": "browsingContext.traverseHistory",
"params": {
"context": "<contextId>",
"delta": <integer>
}
}The params field contains:
contextA string that contains the ID of the top-level context whose session history is to be navigated. Context IDs are returned by commands such as browsingContext.getTree.
deltaAn integer that specifies the number of history entries to move in the session history. A positive value moves the context forward in history; a negative value moves it backward.
The result field in the response is an empty object ({}). The command returns once the traversal has been queued, before the resulting navigation is complete. The browsingContext.historyUpdated event fires when the traversal is complete.
invalid argumentA required parameter is missing or has an invalid type. This error is also returned when the specified context is not a top-level context.
no such frameNo context with the given context ID is found.
no such history entryThe position in the session history specified by delta does not exist.
Assume you have a WebDriver BiDi connection and an active session.
Suppose you created a tab using browsingContext.create and navigated it through several pages using browsingContext.navigate: from https://example.com/page1.html to https://example.com/page2.html, and then to https://example.com/page3.html. To navigate two history entries back, that is, to skip https://example.com/page2.html and land at https://example.com/page1.html, send the following message:
{
"id": 1,
"method": "browsingContext.traverseHistory",
"params": {
"context": "5e5e96e8-5247-4f22-9b35-a4a2d841cbaa",
"delta": -2
}
}The browser queues the history traversal and responds as follows:
{
"id": 1,
"type": "success",
"result": {}
}Continuing from the previous example, to navigate one history entry forward, landing at https://example.com/page2.html, send the following message:
{
"id": 2,
"method": "browsingContext.traverseHistory",
"params": {
"context": "5e5e96e8-5247-4f22-9b35-a4a2d841cbaa",
"delta": 1
}
}The browser queues the history traversal and responds as follows:
{
"id": 2,
"type": "success",
"result": {}
}browsingContext.navigate commandbrowsingContext.reload commandbrowsingContext.create commandbrowsingContext.getTree commandbrowsingContext.navigationStarted eventbrowsingContext.navigationCommitted eventbrowsingContext.navigationFailed eventbrowsingContext.historyUpdated event