No results for

Powered byAlgolia
⚠️ This is the archived documentation for k6 v0.46. Go to the latest version.

newContext([options])

Creates and returns a new BrowserContext, if one hasn't already been initialized for the Browser. If one has already been initialized an error is thrown.

note

A 1-to-1 mapping between Browser and BrowserContext means you cannot run BrowserContexts concurrently. Due to this restriction, if one already exists, it must be closed first before creating a new one.

ParameterTypeDefaultDescription
options
objectnull

Returns

TypeDescription
objectBrowserContext object

deviceScaleFactor example

import { browser } from 'k6/experimental/browser';
export const options = {
scenarios: {
browser: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
}
export default async function () {
const context = browser.newContext({
viewport: {
width: 375,
height: 812,
},
deviceScaleFactor: 3,
});
const page = context.newPage();
try {
await page.goto('https://test.k6.io/');
} finally {
page.close();
}
}