---
title: "goForward([options]) | Grafana k6 documentation"
description: "Browser module: page.goForward([options]) method"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# goForward(\[options])

Returns the main resource response for the navigation, or `null` if the navigation is impossible (e.g., when already at the end of the session history).

Navigates forward in the browser session history. This method is safer than `page.evaluate(() => window.history.forward())`, which can cause race conditions if the page is mid-navigation.

Expand table

| Parameter         | Type   | Default | Description                                                                                                                                                                                |
|-------------------|--------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| options           | object | `null`  |                                                                                                                                                                                            |
| options.timeout   | number | `30000` | Maximum operation time in milliseconds. Pass `0` to disable the timeout. The default value can be changed via the methods listed below. Setting the value to `0` will disable the timeout. |
| options.waitUntil | string | `load`  | When to consider operation to have succeeded. See [Events](#events) for more details.                                                                                                      |

### Methods to Change Default Values

You can change the default value using one of the following methods:

- [browserContext.setDefaultNavigationTimeout(timeout)](/docs/k6/next/javascript-api/k6-browser/browsercontext/setdefaultnavigationtimeout/)
- [browserContext.setDefaultTimeout(timeout)](/docs/k6/next/javascript-api/k6-browser/browsercontext/setdefaulttimeout/)
- [page.setDefaultNavigationTimeout(timeout)](/docs/k6/next/javascript-api/k6-browser/page/setdefaultnavigationtimeout/)
- [page.setDefaultTimeout(timeout)](/docs/k6/next/javascript-api/k6-browser/page/setdefaulttimeout/) |

### Events

> Caution
> 
> Avoid using `networkidle` for testing. This event might never fire on websites with high network activity. Instead, use web assertions to assess when the page is ready.

You can set the event to one of the following:

- `'domcontentloaded'`: The `DOMContentLoaded` event fires.
- `'load'`: The `load` event fires.
- `'networkidle'`: There are no network connections for at least 500 ms.

### Returns

Expand table

| Type                      | Description                                                                                                                                                                      |
|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `Promise<Response | null` | A Promise that fulfills with the [Response](/docs/k6/next/javascript-api/k6-browser/response/)&gt; instance associated with the page, else `null` if navigation is not possible. |

### Example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import { browser } from 'k6/browser';
import { check } from 'k6';

export const options = {
  scenarios: {
    browser: {
      executor: 'shared-iterations',
      options: {
        browser: {
          type: 'chromium',
        },
      },
    },
  },
};

export default async function () {
  const page = await browser.newPage();

  try {
    // Navigate to first page
    await page.goto('https://test.k6.io/browser.php');
    const url1 = await page.url();
    
    // Navigate to second page
    await page.goto('https://test.k6.io/my_messages.php');
    const url2 = await page.url();
    
    // Go back to first page
    await page.goBack();
    
    // Go forward to second page
    const response = await page.goForward();
    
    // Verify we're back on the second page
    const currentUrl = await page.url();
    check(currentUrl, {
      'went forward to second page': (url) => url.includes('my_messages.php'),
    });
    
    // Verify the response is not null (since navigation was possible)
    check(response, {
      'response is not null': (resp) => resp !== null,
    });
    
    // Attempt to go forward again (should return null since we're at the end of history)
    const nullResponse = await page.goForward();
    check(nullResponse, {
      'goForward at boundary returns null': (resp) => resp === null,
    });
  } finally {
    await page.close();
  }
}
```

### Related

- [page.goBack()](/docs/k6/next/javascript-api/k6-browser/page/goback/) - Navigate back in browser history
- [page.goto()](/docs/k6/next/javascript-api/k6-browser/page/goto/) - Navigate to a specific URL
- [page.reload()](/docs/k6/next/javascript-api/k6-browser/page/reload/) - Reload the current page
