Add delay function

This commit is contained in:
Tyler Perkins 2023-01-30 21:05:20 -05:00
parent f750df107e
commit c87955088d
1 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,11 @@
const puppeteer = require('puppeteer');
function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time);
});
}
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
@ -11,6 +17,11 @@ const puppeteer = require('puppeteer');
const ageButton = await page.$("button[data-test='ageVerificationButton']");
await ageButton.click();
delay(8000);
const firstButton = await page.$("span .button");
await firstButton.click();
await page.screenshot({path: 'screenshot.jpg'});
await browser.close();