No results for

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

newPage([options])

Creates and returns a new Page in a new BrowserContext if a BrowserContext hasn't already been initialized for the Browser. If a BrowserContext 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 retrieved and closed first before creating a new one.

attention

Pages that have been opened ought to be closed using Page.close. Pages left open could potentially distort the results of Web Vital metrics.

ParameterTypeDefaultDescription
options
objectnull

Returns

TypeDescription
objectPage 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 page = browser.newPage({
viewport: {
width: 375,
height: 812,
},
deviceScaleFactor: 3,
});
try {
await page.goto('https://test.k6.io/');
} finally {
page.close();
}
}