Skip to content

Commit 542024f

Browse files
committed
fix: replace deprecated waitFor (resolves: #63)
1 parent 356d7c6 commit 542024f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/browsers/puppeteer/webpage.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ export default class PuppeteerWebpage extends Webpage {
1010
await this.page.goto(url)
1111

1212
if (readyCondition) {
13-
await this.page.waitFor(readyCondition)
13+
let waitFn = 'waitForSelector'
14+
if (typeof readyCondition === 'number') {
15+
waitFn = 'waitForTimeout'
16+
} else if (typeof readyCondition === 'function') {
17+
waitFn = 'waitForFunction'
18+
}
19+
20+
await this.page[waitFn](readyCondition)
1421
}
1522

1623
return this.returnProxy()

test/unit/webpage.puppeteer.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('puppeteer/webpage', () => {
1414
return Promise.resolve({
1515
goto: (...args) => spy('goto', ...args),
1616
waitFor: (...args) => spy('waitFor', ...args),
17+
waitForSelector: (...args) => spy('waitForSelector', ...args),
1718
evaluate: (...args) => spy('evaluate', ...args),
1819
title: (...args) => spy('title', ...args)
1920
})
@@ -27,7 +28,8 @@ describe('puppeteer/webpage', () => {
2728
const webPath = '/'
2829
webpage = await browser.page(webPath)
2930
expect(spy).toHaveBeenCalledWith('goto', webPath)
30-
expect(spy).toHaveBeenCalledWith('waitFor', 'body')
31+
expect(spy).toHaveBeenCalledWith('waitForSelector', 'body')
32+
expect(spy).not.toHaveBeenCalledWith('waitFor')
3133
})
3234

3335
test('should implement getHtml', () => {

0 commit comments

Comments
 (0)