0

does playwright have the support/ features to handle multiple test data for various scenarios and for multiple environments. Could someone point me to the right approach for handling such scenarios.

scenarios:

Test will be executed in multiple environments ( Acceptance, prod etc). test will have multiple scenarios which will require different set of test data. I dont see a proper approach that i can used from the documentation ( or may be i am looking at the wrong place).

thanks in advance. Allen K

Allen
  • 111
  • 1
  • 11

1 Answers1

0

At first you have playwright.config.ts file where you can set projects and their variables. In ex

projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'firefox',
      use: { ...devices['Desktop Firefox'] },
    },
    {
      name: 'webkit',
      use: { ...devices['Desktop Safari'] },
    },

or in your case it can projects with different environment. Or you can create a Json structure of data that will need for particular test like.

{
 "tcs":[]
{
 "name": tc1,
 "field1": value,
 "field2": value,
},
{
 "name": tc2,
 "field1": value,
 "field2": value,
}
}

Then just import this file in your suit and use all the data for particular test in foreach loop.

Gaj Julije
  • 1,538
  • 15
  • 32
  • Julie, i dont think we can add other variables other than defined by playwright inside the projects / playwright config. Also the json data file approach above will not work when you have multiple test data with different scenarios. Also considering the same test can be executed in multiple environments, the test data will be different and the import might not work, unless you have two imports for two json file ( one for each environment) – Allen Feb 09 '22 at 02:54
  • Combining these two, you can achive whatever combination you need. If you need a specific data for each env, you can devide .json file per env and put your data in nasted json structure. Planty of options, give it a try. – Gaj Julije Feb 09 '22 at 12:44