From 16ce5ad0e4f9c871880a76d8a01c07471dca5d58 Mon Sep 17 00:00:00 2001 From: Alex Humphries Date: Fri, 7 Mar 2025 09:37:19 -0500 Subject: [PATCH] Update validateURL to account for more scenarios In some scenarios, the URL will not have already changed by the time this check is being made, so if the check fails, we wait and recheck a few times --- playwright-tests/pages/BasePage.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/playwright-tests/pages/BasePage.ts b/playwright-tests/pages/BasePage.ts index c241c45e..8b881b59 100644 --- a/playwright-tests/pages/BasePage.ts +++ b/playwright-tests/pages/BasePage.ts @@ -116,7 +116,21 @@ export class BasePage { } async validateURL(url: string) { - const currentUrl = this.page.url(); - expect(currentUrl).toEqual(url); + let failCount = 0; + /* + We can't assume that the URL has already changed when we get here, but the point of this + is to help speed up tests, so we want to move on as soon as we can if this passes, but + without waiting too long if it fails + */ + while(failCount < 10) { + await this.page.waitForTimeout(1000); + const currentUrl = this.page.url(); + if(currentUrl == url) + break; + else { + failCount++; + } + } + expect(failCount).not.toEqual(10); } } \ No newline at end of file