How to use the puppeteer-extra.pluginNames function in puppeteer-extra

To help you get started, we’ve selected a few puppeteer-extra examples, based on popular ways it is used in public projects.

github berstend / puppeteer-extra / end-to-end-tests / basic.js View on Github external
const PuppeteerExtraPlugin = require('puppeteer-extra-plugin')
  const pluginName = 'hello-world'
  const pluginData = [ { name: 'foo', value: 'bar' } ]
  class Plugin extends PuppeteerExtraPlugin {
    constructor (opts = { }) { super(opts) }
    get name () { return pluginName }
    get data () { return pluginData }
  }
  const instance = new Plugin()
  puppeteer.use(instance)
  const browser = await puppeteer.launch({ headless: true })
  const page = await browser.newPage()

  t.is(puppeteer.plugins.length, 1)
  t.is(puppeteer.plugins[0].name, pluginName)
  t.is(puppeteer.pluginNames.length, 1)
  t.is(puppeteer.pluginNames[0], pluginName)
  t.is(puppeteer.getPluginData().length, 1)
  t.deepEqual(puppeteer.getPluginData()[0], pluginData[0])
  t.deepEqual(puppeteer.getPluginData('foo')[0], pluginData[0])
  t.is(puppeteer.getPluginData('not-existing').length, 0)

  await page.goto('http://example.com', {waitUntil: 'domcontentloaded'})
  await browser.close()
  t.true(true)
})
github berstend / puppeteer-extra / end-to-end-tests / basic.js View on Github external
const pluginName = 'hello-world'
  const pluginData = [ { name: 'foo', value: 'bar' } ]
  class Plugin extends PuppeteerExtraPlugin {
    constructor (opts = { }) { super(opts) }
    get name () { return pluginName }
    get data () { return pluginData }
  }
  const instance = new Plugin()
  puppeteer.use(instance)
  const browser = await puppeteer.launch({ headless: true })
  const page = await browser.newPage()

  t.is(puppeteer.plugins.length, 1)
  t.is(puppeteer.plugins[0].name, pluginName)
  t.is(puppeteer.pluginNames.length, 1)
  t.is(puppeteer.pluginNames[0], pluginName)
  t.is(puppeteer.getPluginData().length, 1)
  t.deepEqual(puppeteer.getPluginData()[0], pluginData[0])
  t.deepEqual(puppeteer.getPluginData('foo')[0], pluginData[0])
  t.is(puppeteer.getPluginData('not-existing').length, 0)

  await page.goto('http://example.com', {waitUntil: 'domcontentloaded'})
  await browser.close()
  t.true(true)
})

puppeteer-extra

Teach puppeteer new tricks through plugins.

MIT
Latest version published 3 months ago

Package Health Score

85 / 100
Full package analysis