Skip to content

Commit c7e58ab

Browse files
committed
fix(ppt): no context is used for wait* functions
1 parent 8d81ed4 commit c7e58ab

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

lib/helper/Playwright.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ class Playwright extends Helper {
900900
}
901901

902902
async _evaluateHandeInContext(...args) {
903-
const context = (await this.context) || (await this._getContext())
903+
const context = await this._getContext()
904904
return context.evaluateHandle(...args)
905905
}
906906

@@ -1284,7 +1284,7 @@ class Playwright extends Helper {
12841284
* ```
12851285
*/
12861286
async _locate(locator) {
1287-
const context = (await this.context) || (await this._getContext())
1287+
const context = await this._getContext()
12881288

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

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

@@ -1327,7 +1327,7 @@ class Playwright extends Helper {
13271327
* ```
13281328
*/
13291329
async _locateClickable(locator) {
1330-
const context = (await this.context) || (await this._getContext())
1330+
const context = await this._getContext()
13311331
return findClickable.call(this, context, locator)
13321332
}
13331333

@@ -2478,7 +2478,7 @@ class Playwright extends Helper {
24782478
locator = new Locator(locator, 'css')
24792479

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

25082508
let waiter
2509-
const context = (await this.context) || (await this._getContext())
2509+
const context = await this._getContext()
25102510
if (!locator.isXPath()) {
25112511
const valueFn = function ([locator]) {
25122512
return Array.from(document.querySelectorAll(locator)).filter((el) => el.disabled).length > 0
@@ -2534,7 +2534,7 @@ class Playwright extends Helper {
25342534
const locator = new Locator(field, 'css')
25352535
const matcher = await this.context
25362536
let waiter
2537-
const context = (await this.context) || (await this._getContext())
2537+
const context = await this._getContext()
25382538
if (!locator.isXPath()) {
25392539
const valueFn = function ([locator, value]) {
25402540
return (
@@ -2569,7 +2569,7 @@ class Playwright extends Helper {
25692569
locator = new Locator(locator, 'css')
25702570

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

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

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

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

@@ -2737,7 +2737,7 @@ class Playwright extends Helper {
27372737
}
27382738

27392739
async _getContext() {
2740-
if (this.context && this.context.constructor.name === 'FrameLocator') {
2740+
if (this.context && this.context.constructor.name === 'FrameLocator' || this.context) {
27412741
return this.context
27422742
}
27432743
return this.page
@@ -2956,7 +2956,7 @@ class Playwright extends Helper {
29562956
}
29572957
}
29582958
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
2959-
const context = (await this.context) || (await this._getContext())
2959+
const context = await this._getContext()
29602960
return context.waitForFunction(fn, args, { timeout: waitTimeout })
29612961
}
29622962

@@ -3010,7 +3010,7 @@ class Playwright extends Helper {
30103010
locator = new Locator(locator, 'css')
30113011

30123012
let waiter
3013-
const context = (await this.context) || (await this._getContext())
3013+
const context = await this._getContext()
30143014
if (!locator.isXPath()) {
30153015
try {
30163016
await context

lib/helper/Puppeteer.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ class Puppeteer extends Helper {
626626
}
627627

628628
async _evaluateHandeInContext(...args) {
629-
const context = (await this.context) || (await this._getContext())
629+
const context = await this._getContext()
630630
return context.evaluateHandle(...args)
631631
}
632632

@@ -2094,7 +2094,7 @@ class Puppeteer extends Helper {
20942094
locator = new Locator(locator, 'css')
20952095
await this.context
20962096
let waiter
2097-
const context = (await this.context) || (await this._getContext())
2097+
const context = await this._getContext()
20982098
if (locator.isCSS()) {
20992099
const enabledFn = function (locator) {
21002100
const els = document.querySelectorAll(locator)
@@ -2126,7 +2126,7 @@ class Puppeteer extends Helper {
21262126
const locator = new Locator(field, 'css')
21272127
await this.context
21282128
let waiter
2129-
const context = (await this.context) || (await this._getContext())
2129+
const context = await this._getContext()
21302130
if (locator.isCSS()) {
21312131
const valueFn = function (locator, value) {
21322132
const els = document.querySelectorAll(locator)
@@ -2159,7 +2159,7 @@ class Puppeteer extends Helper {
21592159
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
21602160
locator = new Locator(locator, 'css')
21612161
let waiter
2162-
const context = (await this.context) || (await this._getContext())
2162+
const context = await this._getContext()
21632163
if (locator.isCSS()) {
21642164
const visibleFn = function (locator, num) {
21652165
const els = document.querySelectorAll(locator)
@@ -2210,7 +2210,7 @@ class Puppeteer extends Helper {
22102210
locator = new Locator(locator, 'css')
22112211

22122212
let waiter
2213-
const context = (await this.context) || (await this._getContext())
2213+
const context = await this._getContext()
22142214
if (locator.isCSS()) {
22152215
waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout })
22162216
} else {
@@ -2233,7 +2233,7 @@ class Puppeteer extends Helper {
22332233
locator = new Locator(locator, 'css')
22342234
await this.context
22352235
let waiter
2236-
const context = (await this.context) || (await this._getContext())
2236+
const context = await this._getContext()
22372237
if (locator.isCSS()) {
22382238
waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout, visible: true })
22392239
} else {
@@ -2254,7 +2254,7 @@ class Puppeteer extends Helper {
22542254
locator = new Locator(locator, 'css')
22552255
await this.context
22562256
let waiter
2257-
const context = (await this.context) || (await this._getContext())
2257+
const context = await this._getContext()
22582258
if (locator.isCSS()) {
22592259
waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout, hidden: true })
22602260
} else {
@@ -2272,7 +2272,7 @@ class Puppeteer extends Helper {
22722272
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
22732273
locator = new Locator(locator, 'css')
22742274
let waiter
2275-
const context = (await this.context) || (await this._getContext())
2275+
const context = await this._getContext()
22762276
if (locator.isCSS()) {
22772277
waiter = context.waitForSelector(locator.simplify(), { timeout: waitTimeout, hidden: true })
22782278
} else {
@@ -2501,7 +2501,7 @@ class Puppeteer extends Helper {
25012501
}
25022502
}
25032503
const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout
2504-
const context = (await this.context) || (await this._getContext())
2504+
const context = await this._getContext()
25052505
return context.waitForFunction(fn, { timeout: waitTimeout }, ...args)
25062506
}
25072507

@@ -2536,7 +2536,7 @@ class Puppeteer extends Helper {
25362536
locator = new Locator(locator, 'css')
25372537

25382538
let waiter
2539-
const context = (await this.context) || (await this._getContext())
2539+
const context = await this._getContext()
25402540
if (locator.isCSS()) {
25412541
const visibleFn = function (locator) {
25422542
return document.querySelector(locator) === null

0 commit comments

Comments
 (0)