File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff 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 ( )
Original file line number Diff line number Diff 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' , ( ) => {
You can’t perform that action at this time.
0 commit comments