I feel like I'm missing something obvious. I would like to be able to run tests defined in a project with multiple browsers. I cannot do this on the command line:
+ npx playwright test --project=e2e --browser all
Error: Cannot use --browser option when configuration file defines projects. Specify browserName in the projects instead.
But unfortunately, I can only specify one browserName in a project. There are two ways I can think of to address this:
browserName
attribute with the value set to an environment variable.Unfortunately, with either approach I need to invoke Playwright once for each each browser, which complicates things when running in CI because I need to either run serially or spin up multiple runners to run in parallel.
What am I missing? Is there a configuration or CLI command for "run tests in this project using multiple browsers"?
This thread is trying to answer question "Is there a configuration or CLI command for running tests in a project using multiple browsers with Playwright?"
You use projects to define browsers for testing.
A project is logical group of tests running with the same configuration. We use projects so we can run tests on different browsers and devices.
{
name: 'setup',
testMatch: '**/*.setup.ts',
},
{
name: 'e2e',
dependencies: ['setup'],
testMatch: '**/*.spec.ts',
},
{
name: 'e2e-v2',
dependencies: ['setup'],
testMatch: '**/*.v2spec.ts',
use: {
baseURL: `${process.env.ENV_URL}/v2/${process.env.CUSTOMER}-v2/`,
},
},
{
name: 'production monitoring synthetic tests',
dependencies: ['setup'],
testMatch: '**/*.synthetic.spec.ts',
},
}
I don't think this is a good practice. Imho projects are meant mainly to configure browsers. In this setup you would have to have projects like "e2e-chrome", "e2e-firefox" etc.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].