How to use the chrome-remote-interface.Close function in chrome-remote-interface

To help you get started, we’ve selected a few chrome-remote-interface 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 adieuadieu / serverless-chrome / examples / serverless-framework / aws / src / handlers / screencast.js View on Github external
await Page.stopScreencast()

    log('We think the page has finished doing what it do. Rendering video.')
    log(`Interaction took ${Date.now() - interactionStartTime}ms to finish.`)
  } catch (error) {
    console.error(error)
  }

  // @TODO: handle this better —
  // If you don't close the tab, an a subsequent Page.navigate() is unable to load the url,
  // you'll end up printing a PDF of whatever was loaded in the tab previously
  // (e.g. a previous URL) _unless_ you Cdp.New() each time. But still good to close to
  // clear up memory in Chrome
  try {
    log('trying to close tab', tab)
    await Cdp.Close({ id: tab.id })
  } catch (error) {
    log('unable to close tab', tab, error)
  }

  await client.close()

  const renderVideo = async () => {
    await new Promise((resolve, reject) => {
      const args = [
        '-y',
        '-loglevel',
        'warning', // 'debug',
        '-f',
        'image2',
        '-framerate',
        `${options.videoFrameRate}`,
github webhintio / hint / packages / utils-debugging-protocol-common / src / debugging-protocol-connector.ts View on Github external
public async close() {
        debug(`Pending tabs: ${this._tabs.length}`);

        while (this._tabs.length > 0) {
            const tab = this._tabs.pop();

            try {
                await cdp.Close({ id: tab.id, port: (this._client as any).port }); // eslint-disable-line new-cap
            } catch (e) {
                debug(`Couldn't close tab ${tab.id}`);
            }
        }

        try {

            (this._client as any).close();

            /*
             * We need to wait until the browser is closed because
             * in tests if we close the client and at the same time
             * the next test tries to open a new tab, an error is
             * thrown.
             */
            await this.isClosed();
github gwuhaolin / chrome-pool / index.js View on Github external
async closeTab(tabId) {
    try {
      // https://chromedevtools.github.io/devtools-protocol/tot/Target/#method-closeTarget
      await chrome.Close({
        port: this.port,
        id: tabId,
      });
      delete this.tabs[tabId];
    } catch (err) {
      throw err;
    }
  }
github cockpit-project / cockpit / test / common / chromium-cdp-driver.js View on Github external
.on('end', () => {
                       CDP.Close(target)
                           .then(() => process.exit(0))
                           .catch(fatal);
                   });
            })
github N0taN3rd / Squidwarc / lib / remoteChrome.js View on Github external
static Close (...args) {
    return CDP.Close(...args)
  }
github moos / chromate / src / chrome-tab.js View on Github external
function closeTab(tabId, options) {
  return CDP.Close({
    id  : tabId,
    port: options && options.port || Tab.settings.port
  });
}
github N0taN3rd / Squidwarc / lib / crawler / index.js View on Github external
static Close (...args) {
    return CDP.Close(...args)
  }
github ElasticSuite / chrome-print / server.js View on Github external
}).then((screenshot) => {
            const buffer = new Buffer(screenshot.data, 'base64');
            client.close();
            CDP.Close({id: client.target.id, host: cdpHost, port: cdpPort})
              .then(() => resolve(buffer))
              .catch(e => reject(e));
          }).catch((e) => reject(e));
        }, delay);