const puppeteer = require("puppeteer");
const param_puppeteer = {
args: [
"--incognito",
"--ignore-certificate-errors",
"--no-sandbox",
"--disable-setuid-sandbox",
"--window-size=1920,1080",
"--disable-accelerated-2d-canvas",
"--disable-gpu",
// '--unlimited-storage',
// '--no-startup-window',
// '--disable-dev-shm-usage',
// '--disable-crash-reporter',
// '--disable-breakpad'
],
headless: false,
};
async function start() {
return puppeteer
.launch(param_puppeteer)
.then(async (browser) => {
const page = await browser.newPage();
return await task(page)
.catch((err) => console.log(err))
.finally(() => browser.close());
})
.catch((err) => console.log(err));
}
async function task(page) {
await page.setViewport({ width: 1000, height: 1100 });
await page.goto("https://google.com");
await page.waitForSelector("#hplogo");
let exist = await page.$("#hplogo").then((res) => !!res);
if (exist) {
return new Promise((resolve, reject) => resolve("success"));
} else {
return new Promise((resolve, reject) => reject("failed"));
}
}
start();