Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(playwright): Different behavior of see* and waitFor* when used in within #4557

Merged
merged 7 commits into from
Dec 10, 2024
6 changes: 3 additions & 3 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,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 @@ -1300,7 +1300,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 @@ -2737,7 +2737,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
Loading