Set browser options for Playwright tests

A guide to setting the required Chrome arguments for Firefox user preferences for your Playwright tests

Important: Playwright testing on BrowserStack (beta) is not available to all users yet. If you’d like to get access, please submit a request here.

What browser options can be set?

Playwright allows users to set browser arguments for Chromium based browsers and also allows users to set Firefox user preferences if the selected browser is Firefox. All of these can be set while testing on BrowserStack as well.

Set args for Chromium based browsers

You can set args for Chromium based browsers i.e. when you select chrome, edge or playwright-chromium as the browser using the args capability as shown in the example below:

const caps = {
    'browser': 'chrome',
    'browserstack.username': process.env.BROWSERSTACK_USERNAME || 'YOUR_USERNAME',
    'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY || 'YOUR_ACCESS_KEY',
    'args': ['--incognito']  // You can specify an array of strings here. Valid only if browser is chromium based
};

You can specify any argument from the list of all supported Chromium arguments.

Set Firefox user preferences

You can set firefox_user_prefs if the selected browser is playwright-firefox using the capability firefox_user_prefs as shown below:

const caps = {
    'browser': 'chrome',
    'browserstack.username': process.env.BROWSERSTACK_USERNAME || 'YOUR_USERNAME',
    'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY || 'YOUR_ACCESS_KEY',
    'firefox_user_prefs': '<Object<string, string|number|boolean>>'  // You can pass the capability in the same format as supported by Playwright in the launch arguments
};

The firefox_user_prefs capability value can be passed in the same format as supported by Playwright in the launch arguments. You can pass any firefox_user_prefs as supported by Playwright.

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert