---
title: "grantPermissions(permissions[, options]) | Grafana k6 documentation"
description: "Grants specified permissions to the BrowserContext."
---

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

# grantPermissions(permissions\[, options])

Grants specified permissions to the [browser context](/docs/k6/latest/javascript-api/k6-browser/browsercontext/). Only grants corresponding permissions to the given origin if specified.

Expand table

| Parameter      | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                           |
|----------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| permissions    | array  | A string array of permissions to grant. A permission can be one of the following values: `'geolocation'`, `'midi'`, `'midi-sysex'` (system-exclusive midi), `'notifications'`, `'camera'`, `'microphone'`, `'background-sync'`, `'ambient-light-sensor'`, `'accelerometer'`, `'gyroscope'`, `'magnetometer'`, `'accessibility-events'`, `'clipboard-read'`, `'clipboard-write'`, `'payment-handler'`. |
| options        | object | Optional.                                                                                                                                                                                                                                                                                                                                                                                             |
| options.origin | string | The [origin](https://developer.mozilla.org/en-US/docs/Glossary/Origin) to grant permissions to, e.g. `'https://example.com'`.                                                                                                                                                                                                                                                                         |

### Returns

Expand table

| Type            | Description                                                     |
|-----------------|-----------------------------------------------------------------|
| `Promise<void>` | A Promise that fulfills when the permissions have been granted. |

### 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.grantPermissions(['clipboard-read', 'clipboard-write'], {
    origin: 'https://example.com/',
  });
}
```
