I need to run multiple links on a single test. The test scenarios are almost the same for the 4 links, but will have different color or data.
I have tried this, but once link A has failed, it will fail link B,C and D (It will fail the whole test). Is there a way to run those 4 links independently from each other?
test("Validate pages", async () => {
const browser = await chromium.launch({headless: false});
const context = await browser.newContext();
const page = await context.newPage()
const urls = ["linkA", "linkB", "linkC", "linkD"]
for (let i = 0; i < urls.length; i++) {
const url = urls[i];
await page.goto(`${url}`);
// insert test code here that needs to run on the 4 links.
}
}
One Approach : You can use dotenv / Crossenv for this, set the links into environment env files based on the environment. then using Interpolation construct the dynamic path to the dotenv config. so on every run u call different link based on environment and execute ur testcase.