How to use the puppeteer.connect function in puppeteer

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / puppeteer_v1.20.x / flow_v0.76.x-v0.103.x / test_puppeteer_v1.20.x_connect.js View on Github external
it('should complain if an option arg key is of the wrong type', () => {
    // $ExpectError string is incompatible with boolean in property `ignoreHTTPSErrors`
    puppeteer.connect({ ignoreHTTPSErrors: 'testing...' });
  });
  it('should preserve Browser type', () => {
github qmlweb / qmlweb / tests / chromium.callback.js View on Github external
async function main() {
  let info;
  while (!info) {
    info = await attempt();
  }
  const browser = await puppeteer.connect({
    browserWSEndpoint: info.webSocketDebuggerUrl
  });
  const pages = await browser.pages();
  const page = pages[0];
  page.evaluate(`
    window.top.chromeScreenshot = async function(options = {}) {
      const response = await fetch(
        "http://localhost:${port}/screenshot" +
        "?rand=" + Math.random().toString(36) +
        "&options=" + encodeURIComponent(JSON.stringify(options)) +
        "&secret=${encodeURIComponent(secret)}"
      );
      const base64 = await response.text();
      return base64;
    };
  `);
github yanivefraim / react-tdd-workshop / test / helpers / environment.js View on Github external
async setup() {
    await super.setup();

    const browserWSEndpoint = fs.readFileSync(path.join(DIR, 'wsEndpoint'), 'utf8');

    if (!browserWSEndpoint) {
      throw new Error('wsEndpoint not found');
    }

    this.global.BROWSER = await puppeteer.connect({
      browserWSEndpoint,
    });
  }
};
github jj4th / jest-puppeteer-performance / src / puppeteer_environment.ts View on Github external
async setup() {
    console.log('Setup Test Environment.');
    await super.setup();
    const wsEndpoint = fs.readFileSync(path.join(DIR, 'wsEndpoint'), 'utf8');
    if (!wsEndpoint) {
      throw new Error('wsEndpoint not found');
    }
    this.global.__METRICS__ = loadMetricsData();
    this.global.__BROWSER__ = await puppeteer.connect({
      browserWSEndpoint: wsEndpoint,
    })
  }
github authcov / authcov / lib / crawler / browser.js View on Github external
static async init(config) {
    const maxConcurrency = (config.maxConcurrency !== undefined) ? config.maxConcurrency : 10;
    let puppeteer_browser;
    let browserLaunched;

    if(config.browserURL !== undefined) {
      puppeteer_browser = await Puppeteer.connect({
        browserURL: config.browserURL
      });
      browserLaunched = false;

    } else if(config.browserWSEndpoint !== undefined) {
      puppeteer_browser = await Puppeteer.connect({
        browserWSEndpoint: config.browserWSEndpoint
      });
      browserLaunched = false;

    } else {
      puppeteer_browser = await Puppeteer.launch({
        headless: config.headless,
        args: ['--disable-web-security']
      });
      browserLaunched = true;
github HuddleEng / Muppeteer / src / TestController.js View on Github external
async launchBrowser({
        headless = true,
        existingWebSocketUri,
        disableSandbox = false,
        executablePath = null,
        useDocker = true
    } = {}) {
        if (existingWebSocketUri) {
            this.isUsingDocker = useDocker;

            this.browser = await puppeteer.connect({
                browserWSEndpoint: existingWebSocketUri
            });

            return this.browser;
        }

        if (useDocker) {
            const webSocketUri = await dockerRunChromium();

            this.browser = await puppeteer.connect({
                browserWSEndpoint: webSocketUri
            });

            this.isUsingDocker = useDocker;
        } else {
            const launchConfig = {
github NimaSoroush / differencify / src / target.js View on Github external
async connect(options) {
    try {
      this.prefixedLogger.log('Launching browser...');
      this.browser = await puppeteer.connect(options);
      this.testConfig.newWindow = true;
    } catch (error) {
      this._logError(error);
      throw new Error('Failed to launch the browser');
    }
    return this.browser;
  }
github NimaSoroush / differencify / src / index.js View on Github external
async connectBrowser(options) {
    if (!this.browser) {
      logger.log('Launching browser...');
      try {
        this.browser = await puppeteer.connect(options);
      } catch (error) {
        logger.trace(error);
      }
    } else {
      logger.log('Using existing browser instance');
    }
  }