Skip to content

Instantly share code, notes, and snippets.

@rodrigogs
Created September 27, 2019 20:14
Show Gist options
  • Save rodrigogs/7db680570b04b0d2808cf482b2b5548c to your computer and use it in GitHub Desktop.
Save rodrigogs/7db680570b04b0d2808cf482b2b5548c to your computer and use it in GitHub Desktop.
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);
}
})();
{
"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