Dump and restore session data from your puppeteer pages.
This plugin supports:
- cookies
- localStorage
- sessionStorage
- IndexedDB (you'll need to specify the
securityOriginof the databases to dump)
yarn add puppeteer-extra-plugin-session
# or
npm install puppeteer-extra-plugin-sessionFirst of all, you have to register the plugin with puppeteer-extra.
JavaScript:
puppeteer.use(require('puppeteer-extra-plugin-session')())TypeScript:
import SessionPlugin from 'puppeteer-extra-plugin-session';
puppeteer.use(SessionPlugin())Then, you'll have access to session data helpers:
const securityOrigin = "https://github.com"; // security origin of the target IndexedDB
const sessionData = await page.sessionManager.dump(); // or page.sessionManager.dumpString()
// [...]
await page.sessionManager.restore(sessionData); // or page.sessionManager.restoreString(sessionData)Tests are defined in *.spec.ts files.
You can run the tests watcher using yarn test or npm run test
You can see the package's logs by setting the DEBUG=puppeteer-extra-plugin:session env variable.
Example: DEBUG=puppeteer-extra-plugin:session npm test
See the core Puppeteer-Extra Plugin docs for additional information: https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin
We appreciate all contributions.
See TODO.md
MIT
