Features

Browser Options

This document will guide you in specifying custom browser options, which can be used with Playwright testing.

You can change the browser start arguments for a Chromium-based browser, or pass user-preferences for the Firefox browser.

Set args for Chromium browsers

In the example below we'll set custom browser args which will be used by the browser upon startup.

const startupFlags = []
startupFlags.push('--window-size=1280,720')
startupFlags.push('--hide-scrollbars')

const browser = await pw.chromium.connect({
  wsEndpoint: `wss://cloud.testingbot.com/playwright` + 
  `?key=api_key&secret=api_secret&browserName=chrome&startupFlags=${JSON.stringify(startupFlags)}`
})

const page = await browser.newPage()
await page.goto('https://testingbot.com')
browser.close()

You can use any of the Chromium commandline switches.

Set Firefox user preferences

If you are running a Playwright test on Firefox, you can set the Firefox User Preferences.

const firefoxPrefs = {
	'browser.autoFocus': true
}

const browser = await pw.firefox.connect({
  wsEndpoint: `wss://cloud.testingbot.com/playwright` + 
  `?key=api_key&secret=api_secret&browserName=firefox&firefoxUserPrefs=${JSON.stringify(firefoxPrefs)}`
})

const page = await browser.newPage()
await page.goto('https://testingbot.com')
browser.close()

For more information, please see Firefox Preferences.