sincecutoff.com
← all changes

k6/browser Page adds goBack() and goForward()

Introduced 2026-02-10 · score 0.96

HOW TO USE IT

When a k6 browser script needs to test session history, use `page.goBack()` or `page.goForward()` after navigation; await the call and pass optional `{ timeout, waitUntil }` settings as needed.

import { browser } from 'k6/browser'; export const options = { scenarios: { ui: { executor: 'shared-iterations', options: { browser: { type: 'chromium' } } } }, }; export default async function () { const page = await browser.newPage(); try { await page.goto('<first-url>'); await page.goto('<second-url>'); await page.goBack({ timeout: 30000, waitUntil: 'load' }); await page.goForward(); } finally { await page.close(); } }

WHY THIS HELPS

Test browser history navigation in a k6 browser script.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.6.0
  • options: Options object for the history navigation call; defaults to null.
  • options.timeout: Maximum operation time in milliseconds; defaults to 30000. Set to 0 to disable the timeout.
  • options.waitUntil: Navigation success event; defaults to `load`. Allowed values: `domcontentloaded`, `load`, `networkidle`. Docs caution that `networkidle` may never fire on busy sites.
  • Prerequisite: A browser scenario must specify an executor and set `options.browser.type` to `chromium`.
  • Prerequisite: Install k6 and a Chromium-based browser, or use a Docker image with Chromium built in.
  • The methods support optional timeout and `waitUntil` parameters.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card