No results for

Powered byAlgolia
⚠️ This is the archived documentation for k6 v0.45.

Browser class

The Browser class is the entry point for all your tests, and it is what interacts with the actual web browser via Chrome DevTools Protocol (CDP). It manages:

  • BrowserContext which is where you can set a variety of attributes to control the behavior of pages;
  • and Page which is where your rendered site is displayed.

A new Browser instance (hence a new browser process) can be created using the launch() method of the chromium module from 'k6/experimental/browser'.

browser.close()Closes the browser and all of its pages (if any were opened).
browser.contexts()Lets you access all open BrowserContexts.
Indicates whether the CDP connection to the browser process is active or not.
Creates and returns a new BrowserContext.
Creates a new Page in a new BrowserContext and returns the page.
browser.on('disconnected')Detects the disconnected event from the browser application.
browser.version()Returns the browser application's version.


import { chromium } from 'k6/experimental/browser';
export default async function () {
const browser = chromium.launch();
const context = browser.newContext();
const page = context.newPage();
try {
await page.goto('');
} finally {