当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript puppeteer.launch函数代码示例

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


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

示例1: launch

  t.test('switch account not needed', async t => {
    const browser = await launch(PUPPETEER_LAUNCH_OPTIONS)
    const page    = await browser.newPage()

    await page.setContent('<h1>ok</h1>')
    const clicked = await bridge.clickSwitchAccount(page)

    await page.close()
    await browser.close()

    t.equal(clicked, false, 'should no button found')
  })
开发者ID:miggame,项目名称:wechaty,代码行数:12,代码来源:bridge.spec.ts

示例2:

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  page.setDefaultTimeout(100000);
  await page.goto("https://news.ycombinator.com", { waitUntil: "networkidle0" });
  await page.pdf({ path: "hn.pdf", format: "A4" });

  const frame = page.frames()[0];
  await frame.goto('/');

  browser.close();
})();
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:12,代码来源:puppeteer-tests.ts

示例3: async

    b: async () => {
        const browser = await puppet.launch()
        const page = await browser.newPage()

        await page.goto('https://example.com/')
        // await page.screenshot({path: 'example.png'})

        const abc = await page.title()
        ok(abc === 'Example Domain')

        await browser.close()
    }
开发者ID:inad9300,项目名称:kiwibit,代码行数:12,代码来源:main.test.ts

示例4: beforeAll

	beforeAll( async () => {
		browser = await puppeteer.launch( { headless: true } );
		page = await browser.newPage();

		// Print errors from the page
		page.on( 'console', ( msg: any ) => console.log( 'PAGE LOG:', msg.text() ) );
		page.on( 'pageerror', ( err: Error ) => console.error( err ) );

		await page.goto( `file://${__dirname}/test-browser-umd.html`, { 
			waitUntil: 'load' 
		} );
	} );
开发者ID:gregjacobs,项目名称:Autolinker.js,代码行数:12,代码来源:test-browser-umd.spec.ts

示例5:

(async () => {
  const browser = await puppeteer.launch({
    args: [
      '--no-sandbox',
      '--disable-setuid-sandbox',
    ]
  });
  const page = await browser.newPage();
  await page.goto("https://example.com");
  await page.screenshot({ path: "example.png" });

  browser.close();
})();
开发者ID:WorldMaker,项目名称:DefinitelyTyped,代码行数:13,代码来源:puppeteer-tests.ts

示例6:

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto("https://example.com");
  const base64string: string = await page.screenshot({ encoding: "base64" });
  const buffer: Buffer = await page.screenshot({ encoding: "binary" });
  const screenshotOptions: puppeteer.ScreenshotOptions = {
    fullPage: true,
  };
  const stringOrBuffer: string | Buffer = await page.screenshot(screenshotOptions);

  browser.close();
})();
开发者ID:,项目名称:,代码行数:13,代码来源:

示例7: before

  before(async () => {
    this.browser = await puppeteer.launch({
      defaultViewport: {
        width: 1920,
        height: 1080,
      },
      headless: false,
      args: ['--no-sandbox'],
    });

    const bundlePath = path.resolve(__dirname, '../dist/rrweb.min.js');
    this.code = fs.readFileSync(bundlePath, 'utf8');
  });
开发者ID:aftabnaveed,项目名称:rrweb,代码行数:13,代码来源:integration.test.ts


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