No results for

Powered byAlgolia

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/x/browser.

MethodDescription
browserType.connect([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/x/browser';
export default function () {
const browser = chromium.launch();
const context = browser.newContext();
const page = context.newPage();
page
.goto('https://test.k6.io/', {
waitUntil: 'networkidle',
})
.then(() => {
page.screenshot({ path: `example-chromium.png` });
})
.finally(() => {
page.close();
browser.close();
});
}