Once you install Playwright and execute your test, you will find your single test will run on three browsers with two workers running two browsers simultaneously.
Cross-Browser Testing by default is a nice feature, but while creating or debugging scripts, we want to save time by executing on one browser at a time and testing on other browsers.
So you can stop running the scripts on multiple browsers in two ways: by making changes in the config file and giving command line parameters for a specific browser.
Method 1: Comment Other Browser in Config File
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
// {
// name: 'firefox',
// use: {
// ...devices['Desktop Firefox'],
// },
// },
// {
// name: 'webkit',
// use: {
// ...devices['Desktop Safari'],
// },
// },
};
Now, your test will execute on chrome only. This is not an efficient approach, so I would recommend Method 2.
Method 2: Give Command Line Option
npx playwright test testName.spec.ts --project=chromium
- Here, the project can be replaced with p also.
- For Firefox, use value firefox, and for Safari, use webKit.