diff --git a/e2e/cucumber/step-definitions/common-steps.ts b/e2e/cucumber/step-definitions/common-steps.ts index ddc0911..b0b3f8e 100644 --- a/e2e/cucumber/step-definitions/common-steps.ts +++ b/e2e/cucumber/step-definitions/common-steps.ts @@ -180,28 +180,18 @@ When('I click the {string} link', async function (linkText: string) { const selector = `a:has-text("${linkText}")`; console.log(`🌍 Clicking link: ${linkText}`); - // Get current URL - const currentUrl = world.page.url(); - // Click the link await world.page.click(selector); - // Wait a bit for navigation to start - await world.page.waitForTimeout(500); - - // Check if URL changed - const newUrl = world.page.url(); - if (newUrl === currentUrl) { - console.log(`🌍 URL did not change immediately after link click`); - // Wait for any navigation to complete - try { - await world.page.waitForLoadState('domcontentloaded', { timeout: 5000 }); - } catch { - console.log(`🌍 DOMContentLoaded not reached, continuing`); - } - } else { - console.log(`🌍 Page navigated to: ${newUrl}`); + // Wait for navigation to complete + try { + await world.page.waitForLoadState('networkidle', { timeout: 10000 }); + } catch { + console.log(`🌍 Networkidle not reached, continuing`); } + + const newUrl = world.page.url(); + console.log(`🌍 Page navigated to: ${newUrl}`); }); When('I click the {string} wordmark', async function (wordmarkText: string) {