Skip to content

Commit

Permalink
fix(headless): make headless mode work more reliably. (lirantal#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Schaefer <[email protected]>
  • Loading branch information
eschaefer and Eric Schaefer authored Aug 8, 2020
1 parent 1c40558 commit 65cb0e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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} = {}) {
Expand Down

0 comments on commit 65cb0e9

Please sign in to comment.