I'm trying to log into a page, but when headless mode is True it doesn't work, but when it does, this is my code:
const puppeteer = require("puppeteer")
const sqlite3 = require("sqlite3").verbose();
const db = new sqlite3.Database('./db.db');
const fs = require("fs")
const login = async () => {
db.serialize(function() {
db.all("SELECT * from usuarios",async function(err,rows){
try{
console.log("Dormindo ...")
while(true){
if(err) {
console.log(err);
}
else{
for(logins of rows){
var data = Date.now()
const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium',
args:['--no-sandbox', '--Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36', '--lang=en-US,en;q=0.5']
});
await page.goto("https://unite.nike.com.br/oauth.html?client_id=QLegGiUU042XMAUWE4qWL3fPUIrpQTnq&redirect_uri=https%3A%2F%2Fwww.nike.com.br%2Fapi%2Fv2%2Fauth%2Fnike-unite%2Fset&response_type=code&locale=pt_BR&state=", { waitUntil: 'load', timeout:0});
await page.waitForSelector('input[name="emailAddress"]')
await page.type('input[name="emailAddress"]', logins.email)
await page.type('input[name="password"]', logins.password)
await page.click("input[value='ENTRAR']")
await page.waitForTimeout(6000)
await page.screenshot({fullPage: true, path: 'screenshot.png'})
console.log(Date.now() - data)
console.log("Cookie de usuario armazenado!");
browser.close()
}
}
}
}
}
catch(err){
console.log("Erro durante login!",err)
}
})
})
}
I want to be able to login in True Headless Mode, If you can help me I appreciate it, I can't solve this at all, but from what I see when I enter the page with headless false mode, and open devtools, in the browser console there is a message like this:
INFO Fri Jul 16 2021 23:42:16 GMT-0300 (Brasilia Standard Time) OPTIMIZELY: Skipping JSON schema validation.
My theory is that site somehow manages to check whether or not I'm in headless mode, but I don't know how to fix this anyway, since I sent a user-agent and set the language in args:
, someone help me with that please.