Skip to content

Commit

Permalink
fix(playwright): Different behavior of see* and waitFor* when used in…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
kobenguyent authored Dec 10, 2024
1 parent 344aacf commit 6e259e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
}

Expand Down Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/helper/Puppeteer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Puppeteer - BasicAuth', function () {

I = new Puppeteer({
url: siteUrl,
windowSize: '500x700',
// windowSize: '500x700',
show: false,
waitForTimeout: 5000,
waitForAction: 500,
Expand Down

0 comments on commit 6e259e9

Please sign in to comment.