Home > Enterprise >  Java script pausing the script before the browser closes
Java script pausing the script before the browser closes

Time:10-10

Sorry im very new to coding so speak to me like a 5 year old lol but i wanted the script to pause before the browser closes for like 20 seconds, java script

      await page.goto('http://httpbin.org/ip');
      const infos = await create_accinfos(browser, page);
      write_log(true, "Complete infos");
      accounts.write(infos   "\n");
    } catch(e) {
      console.log(e);
    } finally {
      write_log(true, "Done");
      try{
        browser.close();
      } catch(e){};
    }
  })();

CodePudding user response:

You can use setTimeout() method.

setTimeout(() => { browser.close(); }, 20000)

After 20 seconds (20 000 milliseconds) the browser will be closed.

  • Related