No results for

Powered byAlgolia
⚠️ This documentation is outdated. Please visit grafana.com for the latest k6 documentation.📚

BrowserType

The BrowserType is the entry point into launching a browser process; chromium is currently the only supported BrowserType. To use it, import chromium from the top level module k6/experimental/browser.

MethodDescription
browserType.connect(wsURL, [options])Connect attaches k6 browser to an existing browser instance.
browserType.executablePath()Returns the path where the extension expects to find the browser executable.
browserType.launch([options])Launches a new browser process.
browserType.launchPersistentContext(userDataDir, [options])
Launches the browser with persistent storage.
browserType.name()Returns the name of the BrowserType; currently it will return chromium.

Example

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('https://test.k6.io/');
page.screenshot({ path: `example-chromium.png` });
} finally {
page.close();
browser.close();
}
}