From 6e259e996305144406923543ee79a820c1ae9eec Mon Sep 17 00:00:00 2001 From: kobenguyent <7845001+kobenguyent@users.noreply.github.com> Date: Tue, 10 Dec 2024 09:47:46 +0100 Subject: [PATCH] fix(playwright): Different behavior of see* and waitFor* when used in within (#4557) * fix(playwright): no context is used for wait* functions * fix(playwright): no context is used for wait* functions * fix(ppt): no context is used for wait* functions * fix(ppt): no context is used for wait* functions * fix(ppt): no context is used for wait* functions * fix(playwright): no context is used for wait* functions * fix(ppt): no context is used for wait* functions --- lib/helper/Playwright.js | 6 +++--- test/helper/Playwright_test.js | 13 ++++++++++++- test/helper/Puppeteer_test.js | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index 1f606adf4..37c23dd35 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -1283,7 +1283,7 @@ class Playwright extends Helper { * ``` */ async _locate(locator) { - const context = (await this.context) || (await this._getContext()) + const context = await this._getContext() if (this.frame) return findElements(this.frame, locator) @@ -1299,7 +1299,7 @@ class Playwright extends Helper { * ``` */ async _locateElement(locator) { - const context = (await this.context) || (await this._getContext()) + const context = await this._getContext() return findElement(context, locator) } @@ -2736,7 +2736,7 @@ class Playwright extends Helper { } async _getContext() { - if (this.context && this.context.constructor.name === 'FrameLocator') { + if ((this.context && this.context.constructor.name === 'FrameLocator') || this.context) { return this.context } return this.page diff --git a/test/helper/Playwright_test.js b/test/helper/Playwright_test.js index d36bd4347..b410244d4 100644 --- a/test/helper/Playwright_test.js +++ b/test/helper/Playwright_test.js @@ -37,7 +37,7 @@ describe('Playwright', function () { I = new Playwright({ url: siteUrl, - windowSize: '500x700', + // windowSize: '500x700', browser: process.env.BROWSER || 'chromium', show: false, waitForTimeout: 5000, @@ -205,6 +205,17 @@ describe('Playwright', function () { await I.waitToHide('h9') }) + + it('should wait for invisible combined with dontseeElement', async () => { + await I.amOnPage('https://codecept.io/') + await I.waitForVisible('.frameworks') + await I.waitForVisible('[alt="React"]') + await I.waitForVisible('.mountains') + await I._withinBegin('.mountains', async () => { + await I.dontSeeElement('[alt="React"]') + await I.waitForInvisible('[alt="React"]', 2) + }) + }) }) describe('#waitToHide', () => { diff --git a/test/helper/Puppeteer_test.js b/test/helper/Puppeteer_test.js index 9d3ff1aca..6410c4f14 100644 --- a/test/helper/Puppeteer_test.js +++ b/test/helper/Puppeteer_test.js @@ -32,7 +32,7 @@ describe('Puppeteer - BasicAuth', function () { I = new Puppeteer({ url: siteUrl, - windowSize: '500x700', + // windowSize: '500x700', show: false, waitForTimeout: 5000, waitForAction: 500,