From db2bff1f779642bd6264404d16826cca11ee4490 Mon Sep 17 00:00:00 2001 From: Denys Kuchma Date: Tue, 13 Jan 2026 19:05:42 +0200 Subject: [PATCH 1/3] include actual error in waitUrlEquals when URL matches --- lib/helper/Playwright.js | 6 +++++- lib/helper/Puppeteer.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 5ab67f98e..8b18f34a0 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -3557,7 +3557,11 @@ class Playwright extends Helper { .catch(async e => { const currUrl = await this._getPageUrl() // Required because the waitForFunction can't return data. if (/Timeout/i.test(e.message)) { - throw new Error(`expected url to be ${urlPart}, but found ${currUrl}`) + if (urlPart !== currUrl) { + throw new Error(`expected url to be ${urlPart}, but found ${currUrl}`) + } else { + throw new Error(`expected url not loaded, error message: ${e.message}`) + } } else { throw e } diff --git a/lib/helper/Puppeteer.js b/lib/helper/Puppeteer.js index 6ed5f1857..39bfb6183 100644 --- a/lib/helper/Puppeteer.js +++ b/lib/helper/Puppeteer.js @@ -2467,7 +2467,11 @@ class Puppeteer extends Helper { .catch(async e => { const currUrl = await this._getPageUrl() // Required because the waitForFunction can't return data. if (/Waiting failed/i.test(e.message) || /failed: timeout/i.test(e.message)) { - throw new Error(`expected url to be ${urlPart}, but found ${currUrl}`) + if (urlPart !== currUrl) { + throw new Error(`expected url to be ${urlPart}, but found ${currUrl}`) + } else { + throw new Error(`expected url not loaded, error message: ${e.message}`) + } } else { throw e } From 1a8d252944dd7aad42288fe0e94c7a434868f0a6 Mon Sep 17 00:00:00 2001 From: Denys Kuchma Date: Thu, 15 Jan 2026 17:48:07 +0200 Subject: [PATCH 2/3] improve waitUrlEquals implementation --- lib/helper/Playwright.js | 19 ++++++++++--------- lib/helper/Puppeteer.js | 17 +++++++++-------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 8b18f34a0..284894fe1 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -3541,24 +3541,25 @@ class Playwright extends Helper { const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout const baseUrl = this.options.url + let expectedUrl = urlPart if (urlPart.indexOf('http') < 0) { - urlPart = baseUrl + urlPart + expectedUrl = baseUrl + urlPart } return this.page - .waitForFunction( - urlPart => { - const currUrl = decodeURIComponent(decodeURIComponent(decodeURIComponent(window.location.href))) - return currUrl.indexOf(urlPart) > -1 + .waitForURL( + url => { + const currUrl = decodeURIComponent(window.location.href) + return currUrl.indexOf(url) > -1 }, - urlPart, + expectedUrl, { timeout: waitTimeout }, ) .catch(async e => { - const currUrl = await this._getPageUrl() // Required because the waitForFunction can't return data. + const currUrl = await this._getPageUrl() if (/Timeout/i.test(e.message)) { - if (urlPart !== currUrl) { - throw new Error(`expected url to be ${urlPart}, but found ${currUrl}`) + if (!currUrl.includes(expectedUrl)) { + throw new Error(`expected url to be ${expectedUrl}, but found ${currUrl}`) } else { throw new Error(`expected url not loaded, error message: ${e.message}`) } diff --git a/lib/helper/Puppeteer.js b/lib/helper/Puppeteer.js index 39bfb6183..fa96c9bbc 100644 --- a/lib/helper/Puppeteer.js +++ b/lib/helper/Puppeteer.js @@ -2451,24 +2451,25 @@ class Puppeteer extends Helper { const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout const baseUrl = this.options.url + let expectedUrl = urlPart if (urlPart.indexOf('http') < 0) { - urlPart = baseUrl + urlPart + expectedUrl = baseUrl + urlPart } return this.page .waitForFunction( - urlPart => { - const currUrl = decodeURIComponent(decodeURIComponent(decodeURIComponent(window.location.href))) - return currUrl.indexOf(urlPart) > -1 + url => { + const currUrl = decodeURIComponent(window.location.href) + return currUrl.indexOf(url) > -1 }, { timeout: waitTimeout }, - urlPart, + expectedUrl, ) .catch(async e => { - const currUrl = await this._getPageUrl() // Required because the waitForFunction can't return data. + const currUrl = await this._getPageUrl() if (/Waiting failed/i.test(e.message) || /failed: timeout/i.test(e.message)) { - if (urlPart !== currUrl) { - throw new Error(`expected url to be ${urlPart}, but found ${currUrl}`) + if (!currUrl.includes(expectedUrl)) { + throw new Error(`expected url to be ${expectedUrl}, but found ${currUrl}`) } else { throw new Error(`expected url not loaded, error message: ${e.message}`) } From 62ac7b32d5fbe5354c56a83752627b418f7f5a6c Mon Sep 17 00:00:00 2001 From: Denys Kuchma Date: Thu, 15 Jan 2026 20:06:14 +0200 Subject: [PATCH 3/3] fix playwright helper --- lib/helper/Playwright.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 284894fe1..eb109eb08 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -3546,27 +3546,23 @@ class Playwright extends Helper { expectedUrl = baseUrl + urlPart } - return this.page - .waitForURL( - url => { - const currUrl = decodeURIComponent(window.location.href) - return currUrl.indexOf(url) > -1 - }, - expectedUrl, + try { + await this.page.waitForURL( + url => url.href.includes(expectedUrl), { timeout: waitTimeout }, ) - .catch(async e => { - const currUrl = await this._getPageUrl() - if (/Timeout/i.test(e.message)) { - if (!currUrl.includes(expectedUrl)) { - throw new Error(`expected url to be ${expectedUrl}, but found ${currUrl}`) - } else { - throw new Error(`expected url not loaded, error message: ${e.message}`) - } + } catch (e) { + const currUrl = await this._getPageUrl() + if (/Timeout/i.test(e.message)) { + if (!currUrl.includes(expectedUrl)) { + throw new Error(`expected url to be ${expectedUrl}, but found ${currUrl}`) } else { - throw e + throw new Error(`expected url not loaded, error message: ${e.message}`) } - }) + } else { + throw e + } + } } /**