Skip to content

Instantly share code, notes, and snippets.

@ragog
Created October 20, 2020 13:55
Show Gist options
  • Save ragog/af279e0f2a00ad0058602309a4e62439 to your computer and use it in GitHub Desktop.
Save ragog/af279e0f2a00ad0058602309a4e62439 to your computer and use it in GitHub Desktop.
const { chromium } = require('playwright')
const fs = require('fs');
(async () => {
const browser = await chromium.launch()
const context = await browser.newContext()
const page = await context.newPage()
await page.goto('https://github.com/login')
await page.type('#login_field', process.env.GITHUB_USER)
await page.type('#password', process.env.GITHUB_PWD)
await page.waitForSelector('.js-cookie-consent-reject')
await page.click('.js-cookie-consent-reject')
await page.$eval('[name="commit"]', (elem) => elem.click())
await page.waitForNavigation()
const cookies = await context.cookies()
const cookieJson = JSON.stringify(cookies)
fs.writeFileSync('cookies.json', cookieJson)
await browser.close()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment