From 65cb0e9a2fdfb1de218f64bd0ac598b8182e38fc Mon Sep 17 00:00:00 2001 From: Eric Schaefer Date: Sat, 8 Aug 2020 23:39:59 +0200 Subject: [PATCH] fix(headless): make headless mode work more reliably. (#49) Co-authored-by: Eric Schaefer --- src/Plugins.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Plugins.js b/src/Plugins.js index a81d027..0921e97 100644 --- a/src/Plugins.js +++ b/src/Plugins.js @@ -34,6 +34,12 @@ module.exports.GoogleSocialLogin = async function GoogleSocialLogin(options = {} let page = await browser.newPage() let originalPageIndex = 1 await page.setViewport({width: 1280, height: 800}) + await page.setExtraHTTPHeaders({ + 'Accept-Language': 'en-US;q=0.9,en;q=0.8' + }) + await page.setUserAgent( + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36' + ) await page.goto(options.loginUrl) await login({page, options}) @@ -107,11 +113,9 @@ async function login({page, options} = {}) { } async function typeUsername({page, options} = {}) { - let buttonSelector = options.headless ? '#next' : '#identifierNext' - await page.waitForSelector('input[type="email"]') await page.type('input[type="email"]', options.username) - await page.click(buttonSelector) + await page.click('#identifierNext') } async function typePassword({page, options} = {}) {