Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ class Playwright extends Helper {
}

async _evaluateHandeInContext(...args) {
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
return context.evaluateHandle(...args)
}

Expand Down Expand Up @@ -1327,7 +1327,7 @@ class Playwright extends Helper {
* ```
*/
async _locateClickable(locator) {
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
return findClickable.call(this, context, locator)
}

Expand Down Expand Up @@ -2478,7 +2478,7 @@ class Playwright extends Helper {
locator = new Locator(locator, 'css')

let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (!locator.isXPath()) {
const valueFn = function ([locator]) {
return Array.from(document.querySelectorAll(locator)).filter((el) => !el.disabled).length > 0
Expand Down Expand Up @@ -2506,7 +2506,7 @@ class Playwright extends Helper {
locator = new Locator(locator, 'css')

let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (!locator.isXPath()) {
const valueFn = function ([locator]) {
return Array.from(document.querySelectorAll(locator)).filter((el) => el.disabled).length > 0
Expand Down Expand Up @@ -2534,7 +2534,7 @@ class Playwright extends Helper {
const locator = new Locator(field, 'css')
const matcher = await this.context
let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (!locator.isXPath()) {
const valueFn = function ([locator, value]) {
return (
Expand Down Expand Up @@ -2569,7 +2569,7 @@ class Playwright extends Helper {
locator = new Locator(locator, 'css')

let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
const visibleFn = function ([locator, num]) {
const els = document.querySelectorAll(locator)
Expand Down Expand Up @@ -2613,7 +2613,7 @@ class Playwright extends Helper {
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
locator = new Locator(locator, 'css')

const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
try {
await context.locator(buildLocatorString(locator)).first().waitFor({ timeout: waitTimeout, state: 'attached' })
} catch (e) {
Expand All @@ -2631,7 +2631,7 @@ class Playwright extends Helper {
async waitForVisible(locator, sec) {
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
locator = new Locator(locator, 'css')
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
let count = 0

// we have this as https://github.com/microsoft/playwright/issues/26829 is not yet implemented
Expand Down Expand Up @@ -2660,7 +2660,7 @@ class Playwright extends Helper {
async waitForInvisible(locator, sec) {
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
locator = new Locator(locator, 'css')
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
let waiter
let count = 0

Expand Down Expand Up @@ -2690,7 +2690,7 @@ class Playwright extends Helper {
async waitToHide(locator, sec) {
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
locator = new Locator(locator, 'css')
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
let waiter
let count = 0

Expand Down Expand Up @@ -2956,7 +2956,7 @@ class Playwright extends Helper {
}
}
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
return context.waitForFunction(fn, args, { timeout: waitTimeout })
}

Expand Down Expand Up @@ -3010,7 +3010,7 @@ class Playwright extends Helper {
locator = new Locator(locator, 'css')

let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (!locator.isXPath()) {
try {
await context
Expand Down
20 changes: 10 additions & 10 deletions lib/helper/Puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class Puppeteer extends Helper {
}

async _evaluateHandeInContext(...args) {
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
return context.evaluateHandle(...args)
}

Expand Down Expand Up @@ -2094,7 +2094,7 @@ class Puppeteer extends Helper {
locator = new Locator(locator, 'css')
await this.context
let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
const enabledFn = function (locator) {
const els = document.querySelectorAll(locator)
Expand Down Expand Up @@ -2126,7 +2126,7 @@ class Puppeteer extends Helper {
const locator = new Locator(field, 'css')
await this.context
let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
const valueFn = function (locator, value) {
const els = document.querySelectorAll(locator)
Expand Down Expand Up @@ -2159,7 +2159,7 @@ class Puppeteer extends Helper {
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
locator = new Locator(locator, 'css')
let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
const visibleFn = function (locator, num) {
const els = document.querySelectorAll(locator)
Expand Down Expand Up @@ -2210,7 +2210,7 @@ class Puppeteer extends Helper {
locator = new Locator(locator, 'css')

let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout })
} else {
Expand All @@ -2233,7 +2233,7 @@ class Puppeteer extends Helper {
locator = new Locator(locator, 'css')
await this.context
let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout, visible: true })
} else {
Expand All @@ -2254,7 +2254,7 @@ class Puppeteer extends Helper {
locator = new Locator(locator, 'css')
await this.context
let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout, hidden: true })
} else {
Expand All @@ -2272,7 +2272,7 @@ class Puppeteer extends Helper {
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
locator = new Locator(locator, 'css')
let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout, hidden: true })
} else {
Expand Down Expand Up @@ -2501,7 +2501,7 @@ class Puppeteer extends Helper {
}
}
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
return context.waitForFunction(fn, { timeout: waitTimeout }, ...args)
}

Expand Down Expand Up @@ -2536,7 +2536,7 @@ class Puppeteer extends Helper {
locator = new Locator(locator, 'css')

let waiter
const context = await this._getContext()
const context = (await this.context) || (await this._getContext())
if (locator.isCSS()) {
const visibleFn = function (locator) {
return document.querySelector(locator) === null
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
13 changes: 12 additions & 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 Expand Up @@ -193,6 +193,17 @@ describe('Puppeteer', function () {
.then(() => I.dontSeeElement('//div[@id="step_1"]'))
.then(() => I.dontSee('Step One Button'))
})

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('#waitNumberOfVisibleElements', () => {
Expand Down
Loading