diff --git a/extensions/postLoadDelay/postLoadDelay.js b/extensions/postLoadDelay/postLoadDelay.js index a30c6e232..123c6927e 100644 --- a/extensions/postLoadDelay/postLoadDelay.js +++ b/extensions/postLoadDelay/postLoadDelay.js @@ -3,6 +3,8 @@ */ "use strict"; +const { setTimeout } = require("timers/promises"); + module.exports = function (phantomas) { // e.g. --post-load-delay 5 var delay = parseInt(phantomas.getParam("post-load-delay"), 10); @@ -14,9 +16,9 @@ module.exports = function (phantomas) { // https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#framewaitforselectororfunctionortimeout-options-args phantomas.log("Will wait %d second(s) after load", delay); - phantomas.on("beforeClose", (page) => { + phantomas.on("beforeClose", async (page) => { phantomas.log("Sleeping for %d seconds", delay); - return page.waitForTimeout(delay * 1000); + return setTimeout(delay * 1000); }); };