---
title: "setOffline(offline) | Grafana k6 documentation"
description: "Toggles the BrowserContext's connectivity on/off."
---

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

# setOffline(offline)

Toggles the [browser context](/docs/k6/next/javascript-api/k6-browser/browsercontext/)’s connectivity on/off.

Expand table

| Parameter | Type    | Default | Description                                                                                                                                           |
|-----------|---------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| offline   | boolean | `false` | Whether to emulate the [browser context](/docs/k6/next/javascript-api/k6-browser/browsercontext/) being disconnected (`true`) or connected (`false`). |

### Returns

Expand table

| Type            | Description                                                 |
|-----------------|-------------------------------------------------------------|
| `Promise<void>` | A Promise that fulfills when the connectivity has been set. |

### Example

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

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

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

export default async function () {
  const context = await browser.newContext();

  await context.setOffline(true);

  const page = await context.newPage();

  try {
    // Will not be able to load the page
    await page.goto('https://test.k6.io/browser.php');
  } finally {
    await page.close();
  }
}
```
