Skip to content

Commit 6e259e9

Browse files
authored
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
1 parent 344aacf commit 6e259e9

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

lib/helper/Playwright.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ class Playwright extends Helper {
12831283
* ```
12841284
*/
12851285
async _locate(locator) {
1286-
const context = (await this.context) || (await this._getContext())
1286+
const context = await this._getContext()
12871287

12881288
if (this.frame) return findElements(this.frame, locator)
12891289

@@ -1299,7 +1299,7 @@ class Playwright extends Helper {
12991299
* ```
13001300
*/
13011301
async _locateElement(locator) {
1302-
const context = (await this.context) || (await this._getContext())
1302+
const context = await this._getContext()
13031303
return findElement(context, locator)
13041304
}
13051305

@@ -2736,7 +2736,7 @@ class Playwright extends Helper {
27362736
}
27372737

27382738
async _getContext() {
2739-
if (this.context && this.context.constructor.name === 'FrameLocator') {
2739+
if ((this.context && this.context.constructor.name === 'FrameLocator') || this.context) {
27402740
return this.context
27412741
}
27422742
return this.page

test/helper/Playwright_test.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Playwright', function () {
3737

3838
I = new Playwright({
3939
url: siteUrl,
40-
windowSize: '500x700',
40+
// windowSize: '500x700',
4141
browser: process.env.BROWSER || 'chromium',
4242
show: false,
4343
waitForTimeout: 5000,
@@ -205,6 +205,17 @@ describe('Playwright', function () {
205205

206206
await I.waitToHide('h9')
207207
})
208+
209+
it('should wait for invisible combined with dontseeElement', async () => {
210+
await I.amOnPage('https://codecept.io/')
211+
await I.waitForVisible('.frameworks')
212+
await I.waitForVisible('[alt="React"]')
213+
await I.waitForVisible('.mountains')
214+
await I._withinBegin('.mountains', async () => {
215+
await I.dontSeeElement('[alt="React"]')
216+
await I.waitForInvisible('[alt="React"]', 2)
217+
})
218+
})
208219
})
209220

210221
describe('#waitToHide', () => {

test/helper/Puppeteer_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Puppeteer - BasicAuth', function () {
3232

3333
I = new Puppeteer({
3434
url: siteUrl,
35-
windowSize: '500x700',
35+
// windowSize: '500x700',
3636
show: false,
3737
waitForTimeout: 5000,
3838
waitForAction: 500,

0 commit comments

Comments
 (0)