From 341e4d39273b039a5fcae583b65bd4d955551353 Mon Sep 17 00:00:00 2001 From: Yetkin Timocin Date: Wed, 1 May 2024 08:47:02 -0700 Subject: [PATCH] Changing the place of page.reload in the tests (#1492) Signed-off-by: ytimocin --- playwright/playwright.config.ts | 2 +- playwright/tests/eshop/eshop.app.spec.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/playwright/playwright.config.ts b/playwright/playwright.config.ts index 23dca4b8..a44ba2e0 100644 --- a/playwright/playwright.config.ts +++ b/playwright/playwright.config.ts @@ -47,7 +47,7 @@ export default defineConfig({ use: { ...devices["Desktop Safari"] }, }, ], - timeout: 5 * 60 * 1000, + timeout: 1 * 60 * 1000, expect: { timeout: 30 * 1000, }, diff --git a/playwright/tests/eshop/eshop.app.spec.ts b/playwright/tests/eshop/eshop.app.spec.ts index 143321bc..93ebcda1 100644 --- a/playwright/tests/eshop/eshop.app.spec.ts +++ b/playwright/tests/eshop/eshop.app.spec.ts @@ -92,6 +92,12 @@ test("eShop on Containers App Basic UI and Functionality Checks", async ({ while (attempts < maxAttempts) { try { + // If the item is not found in the first attempt, + // reload the page to trigger the API call again. + if (attempts > 0) { + await page.reload(); + } + await page.waitForSelector(firstItemSelector); firstItem = page.locator(firstItemSelector); await expect(firstItem).toBeVisible(); @@ -102,7 +108,6 @@ test("eShop on Containers App Basic UI and Functionality Checks", async ({ } catch (error) { // If the item is not found within 5 seconds, an error will be thrown here, then the page will be reloaded console.error("Item not found:", error); - await page.reload(); attempts++; } }