當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。