Created
September 27, 2019 20:14
-
-
Save rodrigogs/7db680570b04b0d2808cf482b2b5548c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Polly } = require('@pollyjs/core'); | |
const PuppeteerAdapter = require('@pollyjs/adapter-puppeteer'); | |
// const FSPersister = require('@pollyjs/persister-fs'); | |
const puppeteer = require('puppeteer'); | |
Polly.register(PuppeteerAdapter); | |
// Polly.register(FSPersister); | |
(async () => { | |
try { | |
const browser = await puppeteer.launch({headless: false}); | |
const page = await browser.newPage(); | |
await page.setRequestInterception(true); | |
new Polly('Test', { | |
mode: 'record', | |
adapters: ['puppeteer'], | |
// persister: ['fs'], | |
adapterOptions: { | |
puppeteer: {page}, | |
}, | |
}); | |
await page.goto('https://accounts.google.com/ServiceLogin'); | |
await page.waitFor('input[name=identifier]'); | |
await page.$eval('input[name=identifier]', el => el.value = '[email protected]'); | |
await page.click('#identifierNext'); | |
} catch (err) { | |
console.error(err); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "polly-puppeteer", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node index.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@pollyjs/adapter-puppeteer": "^2.6.2", | |
"@pollyjs/core": "^2.6.2", | |
"@pollyjs/persister-fs": "^2.6.2", | |
"puppeteer": "^1.20.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment