@@ -53,25 +53,34 @@ export const visitPaperPage = async (browser, target, options = {}) => {
5353 let screenshotTimeout , querySelectorTimeout ;
5454 p . waitForSelector ( "meta[name='pm-complete-secret-html']" ) . then ( ( ) => {
5555 clearTimeout ( querySelectorTimeout ) ;
56+ clearTimeout ( screenshotTimeout ) ;
5657 resolve ( ) ;
5758 } ) ;
5859 querySelectorTimeout = setTimeout ( async ( ) => {
5960 screenshotTimeout = setTimeout ( async ( ) => {
60- if ( ! fs . existsSync ( `./tmp` ) ) {
61- fs . mkdirSync ( `./tmp` ) ;
61+ console . log (
62+ `It's taking a while to find the selector for ${ target } : taking a screenshot`
63+ ) ;
64+ if ( ! fs . existsSync ( `${ root } /tmp` ) ) {
65+ console . log ( `Creating tmp directory in ${ root } /tmp` ) ;
66+ fs . mkdirSync ( `${ root } /tmp` ) ;
6267 }
68+ const screenshotPath = `${ root } /tmp/screenshot_${ Date . now ( ) } _${ target
69+ . replaceAll ( "https://" , "" )
70+ . replaceAll ( "/" , "__" ) } .jpg`;
6371 await p . screenshot ( {
64- path : `./tmp/screenshot_${ Date . now ( ) } _${ target
65- . replaceAll ( "https://" , "" )
66- . replaceAll ( "/" , "__" ) } .jpg`,
72+ path : screenshotPath ,
6773 fullPage : true ,
6874 } ) ;
75+ console . log ( `Screenshot taken and saved to ${ screenshotPath } \n\n` ) ;
6976 resolve ( ) ;
7077 } , 1000 ) ;
78+ console . log ( `\nBackup wait for selector after 5 seconds for ${ target } ` ) ;
7179 const content = await p . evaluate ( ( ) => {
7280 return document . querySelector ( "meta[name='pm-complete-secret-html']" )
7381 ?. content ;
7482 } ) ;
83+ console . log ( `Backup content found: ${ content } ` ) ;
7584 clearTimeout ( screenshotTimeout ) ;
7685 resolve ( ) ;
7786 } , 5000 ) ;
0 commit comments