---
title: "viewportSize() | Grafana k6 documentation"
description: "Browser module: page.viewportSize method"
---

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

# viewportSize()

Returns the page’s size (width and height).

### Returns

Expand table

| Type   | Description                                       |
|--------|---------------------------------------------------|
| Object | An object containing the page’s width and height. |

### 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 page = await browser.newPage();

  await page.setViewportSize({
    width: 640,
    height: 480,
  });
  await page.goto('https://test.k6.io/browser.php');

  console.log(page.viewportSize());
}
```
