Add delay function

This commit is contained in:
Tyler Perkins 2023-01-30 21:05:20 -05:00
parent f750df107e
commit c87955088d

View File

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