QA Wolf logo

QA Wolf

/

Star

2.7k

launch([options])

Launch a Playwright Browser and Context.

By default, we block Google Analytics and Google Tag Manager to avoid interfering with your analytics. Message us and we can block other analytics providers.

// launch a chrome browser and context
const { browser, context } = await launch();
// create a page in the context to use in our test
const page = await context.newPage();
// slow down each action down by 2 seconds
const { context } = await launch({ slowMo: 2000 });
// launch a webkit (safari) browser and context
const { context } = await launch({ browser: "webkit" });
// emulate an iphone to test a responsive site
// full list of devices: https://github.com/microsoft/playwright/blob/v1.8.0/src/server/deviceDescriptors.js
const { context } = await launch({ ...devices["iPhone 8"] });
// emulate a camera and screen for testing recording
const { context } = await launch({
args: [
"--use-fake-device-for-media-stream",
"--use-file-for-fake-video-capture=/root/files/wolf.mjpeg",
"--use-fake-ui-for-media-stream",
],
});
// accept permission prompts
const { context } = await launch({
permissions: ["clipboard-read", "clipboard-write", "geolocation"],
});

Arguments

You can use any option available on launch or newContext, including these commonly used ones:

[options] (Object)

  • [allowTracking] (boolean): Enable analytics tracking. Default: false
  • [args] (Array<string>): Arguments to pass to the browser launch. Useful for testing the camera. Default: []
  • [browser] ("chrome" | "chromium" | "firefox" | "webkit"): Type of browser to launch. Default: "chrome"
  • [devtools] (boolean): Open devtools. Default: false
  • [permissions] (Array<string>): Accept permission prompts. Default: []
  • [slowMo] (number): Slow down each action by a number of milliseconds. Default: 0

Returns: Promise<{ browser, context }>