Skip to content

Commit 65cb0e9

Browse files
eschaeferEric Schaefer
and
Eric Schaefer
authored
fix(headless): make headless mode work more reliably. (#49)
Co-authored-by: Eric Schaefer <eric@amie.so>
1 parent 1c40558 commit 65cb0e9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Plugins.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ module.exports.GoogleSocialLogin = async function GoogleSocialLogin(options = {}
3434
let page = await browser.newPage()
3535
let originalPageIndex = 1
3636
await page.setViewport({width: 1280, height: 800})
37+
await page.setExtraHTTPHeaders({
38+
'Accept-Language': 'en-US;q=0.9,en;q=0.8'
39+
})
40+
await page.setUserAgent(
41+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36'
42+
)
3743

3844
await page.goto(options.loginUrl)
3945
await login({page, options})
@@ -107,11 +113,9 @@ async function login({page, options} = {}) {
107113
}
108114

109115
async function typeUsername({page, options} = {}) {
110-
let buttonSelector = options.headless ? '#next' : '#identifierNext'
111-
112116
await page.waitForSelector('input[type="email"]')
113117
await page.type('input[type="email"]', options.username)
114-
await page.click(buttonSelector)
118+
await page.click('#identifierNext')
115119
}
116120

117121
async function typePassword({page, options} = {}) {

0 commit comments

Comments
 (0)