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')
await 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')
await browser.close()

For more information, please see Firefox Preferences.

Was this page helpful?

Looking for More Help?

Have questions or need more information?
You can reach us via the following channels: