This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.

Open source

pages()

Returns all open Pages in the BrowserContext in the order they were attached. Closing a page removes it without changing the order of the remaining pages. A newly attached page appears at the end.

Returns

TypeDescription
Array<Page>An array of page objects.

Example

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.newPage();
  const pages = context.pages();
  console.log(pages.length); // 1
  await context.close();
}