• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript chrome-launcher.launch函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中chrome-launcher.launch函数的典型用法代码示例。如果您正苦于以下问题:TypeScript launch函数的具体用法?TypeScript launch怎么用?TypeScript launch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了launch函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getDebuggableChrome

/**
 * Attempts to connect to an instance of Chrome with an open remote-debugging
 * port. If none is found, launches a debuggable instance.
 */
async function getDebuggableChrome(flags: Flags) {
  return await launch({
    port: flags.port,
    chromeFlags: parseChromeFlags(flags.chromeFlags),
    logLevel: flags.logLevel
  });
}
开发者ID:manekinekko,项目名称:lighthouse,代码行数:11,代码来源:run.ts


示例2: launchChrome

export function launchChrome(url): [Promise<void>, IChromeProcess] {
    let resolveFinish: (code: number) => void;
    let rejectFinish: (err: Error) => void;
    let launchedChrome: LaunchedChrome;
    let res: IChromeProcess = {
        // crash/finish notification does not work with chrome-launcher
        finish: new Promise<number>((resolve, reject) => {
            resolveFinish = resolve;
            rejectFinish = reject;
        }),
        kill() {
            if (launchedChrome) launchedChrome.kill();
        }
    };

    return [
        chromeLauncher
            .launch({
                startingUrl: url,
                chromeFlags: ["--headless", "--disable-gpu"]
            })
            .then(chrome => {
                launchedChrome = chrome;
            })
            .catch(rejectFinish),
        res
    ];
}
开发者ID:Bobris,项目名称:bobril-build,代码行数:28,代码来源:chromeRunner.ts


示例3: launchChrome

/**
 * Launches Chrome with the specified options.
 *
 * @param {CreateOptions} options the options for Chrome.
 * @returns {Promise<LaunchedChrome>} The launched Chrome instance.
 */
async function launchChrome(options: CreateOptions): Promise<LaunchedChrome> {
  const chrome = await launch({
    port: options.port,
    chromePath: options.chromePath,
    chromeFlags: options.chromeFlags || DEFAULT_CHROME_FLAGS,
  });
  options.port = chrome.port;
  return chrome;
}
开发者ID:timonweb-forks,项目名称:html-pdf-chrome,代码行数:15,代码来源:index.ts


示例4: startChrome

 private async startChrome(): Promise<Client> {
   this.chromeInstance = await launch({
     logLevel: this.options.debug ? 'info' : 'silent',
     port: this.options.cdp.port,
   })
   const target = await CDP.New({
     port: this.chromeInstance.port,
   })
   return await CDP({ target })
 }
开发者ID:nylen,项目名称:chromeless,代码行数:10,代码来源:local.ts


示例5: before

 before(async () => {
   try {
     // Start Chrome and wait for it to start listening for connections.
     chrome = await chromeLauncher.launch({
       chromeFlags: [
         '--disable-gpu',
         '--headless',
       ],
     });
     port = chrome.port;
     await tcpPortUsed.waitUntilUsed(port);
   } catch (err) {
     await chrome.kill();
     throw err;
   }
 });
开发者ID:timonweb-forks,项目名称:html-pdf-chrome,代码行数:16,代码来源:index.ts


示例6: startChrome

  private async startChrome(): Promise<Client> {
    const { port } = this.options.cdp
    this.chromeInstance = await launch({
      logLevel: this.options.debug ? 'info' : 'silent',
      chromeFlags: [
        // Do not render scroll bars
        '--hide-scrollbars',

        // The following options copied verbatim from https://github.com/GoogleChrome/chrome-launcher/blob/master/src/flags.ts

        // Disable built-in Google Translate service
        '--disable-translate',
        // Disable all chrome extensions entirely
        '--disable-extensions',
        // Disable various background network services, including extension updating,
        //   safe browsing service, upgrade detector, translate, UMA
        '--disable-background-networking',
        // Disable fetching safebrowsing lists, likely redundant due to disable-background-networking
        '--safebrowsing-disable-auto-update',
        // Disable syncing to a Google account
        '--disable-sync',
        // Disable reporting to UMA, but allows for collection
        '--metrics-recording-only',
        // Mute any audio
        '--mute-audio',
        // Skip first run wizards
        '--no-first-run',
      ],
      port,
    })
    const target = await CDP.New({
      port,
    })
    return await CDP({ target, port })
  }
开发者ID:13768324554,项目名称:chromeless,代码行数:35,代码来源:local.ts



注:本文中的chrome-launcher.launch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript chrome-launcher.LaunchedChrome类代码示例发布时间:2022-05-24
下一篇:
TypeScript chrome.Cu类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap