I got problem with my script where I am logging in to site. I am using puppeteer-extra-plugin-stealth to prevent headless detection.
The code works fine when running with headless: false. But in headless: true is page acting like it does not see the cookies and I am not logged in. When I checked the cookies in both scenarios they are the same so there should be no problem. The cookies are in browser memory.
I could find any solution so far.
My code:
const puppeteer = require('puppeteer-extra')
const {executablePath} = require('puppeteer')
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin())
const browser = await puppeteer.launch({
"headless": true,
"ignoreHTTPSErrors": true,
"executablePath" = executablePath()
});
const page = await browser.newPage();
await page.goto(url, {
waitUntil: "networkidle0",
});
await page.waitForSelector("x");
await page.click("x");
await page.waitForSelector("x");
await page.type("x", username);
await page.click("x");
await page.waitForSelector("x");
await page.waitForFunction(() => {
const input = document.querySelector("x");
return input && input.offsetWidth > 0 && input.offsetHeight > 0;
});
await page.type("x", password);
await page.click("x");
Thanks for any advice.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/zv18UXq
Comments
Post a Comment