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

TypeScript puppeteer.Page类代码示例

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

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



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

示例1: onLoad

  public async onLoad(page: Page): Promise<void> {
    log.verbose('PuppetPuppeteerBridge', 'initPage() on(load) %s', page.url())

    if (this.state.off()) {
      log.verbose('PuppetPuppeteerBridge', 'initPage() onLoad() OFF state detected. NOP')
      return // reject(new Error('onLoad() OFF state detected'))
    }

    try {
      const emitExist = await page.evaluate(() => {
        return typeof window['emit'] === 'function'
      })
      if (!emitExist) {
        await page.exposeFunction('emit', this.emit.bind(this))
      }

      await this.readyAngular(page)
      await this.inject(page)
      await this.clickSwitchAccount(page)

      this.emit('ready')

    } catch (e) {
      log.error('PuppetPuppeteerBridge', 'init() initPage() onLoad() exception: %s', e)
      await page.close()
      this.emit('error', e)
    }
  }
开发者ID:miggame,项目名称:wechaty,代码行数:28,代码来源:bridge.ts


示例2: takeComponentScreenshot

function* takeComponentScreenshot() {
  const state: ApplicationState = yield select();

  yield put(componentScreenshotStarted());
  try {

    const entries = getPreviewComponentEntries(state);

    console.log(`Taking screenshot of ${entries.length} components...`);

    const clippings: ScreenshotClippings = {};
    for (const entry of entries) {
      clippings[getPreviewClippingNamespace(entry.componentId, entry.previewName)] = entry.bounds;
    }

    const previewUrl = getAllComponentsPreviewUrl(state)
    const browser = state.headlessBrowser;
    const page: Page = yield call(browser.newPage.bind(browser));
    yield call(page.goto.bind(page), previewUrl);
    yield call(page.setViewport.bind(page), getAllComponentsPreviewSize(entries));

    // wait for a bit for all resources to load
    yield call(page.waitForSelector.bind(page), ".__ready");

    const buffer = yield call(page.screenshot.bind(page, { type: "png" }));
    yield put(componentScreenshotTaken(buffer, clippings, "image/png"));

    page.close();
  } catch(e) {
    console.error(e.stack);
  }
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:32,代码来源:screenshots.ts


示例3: async

 return async () => {
     await page.click('#create-app');
     await page.waitForSelector($dialog.selector());
     await page.type($dialog.input('.name'), name);
     await page.type($dialog.textarea('.description'), description);
     await page.click($dialog.button('.create'));
 };
开发者ID:bradparks,项目名称:server,代码行数:7,代码来源:application.test.ts


示例4: embed

          it(`should have one selection instance per ${resolve} view`, async () => {
            await embed(spec(specType, 0, selection));
            for (let i = 0; i < hits[specType].length; i++) {
              const parent = parentSelector(specType, i);
              const store = await page.evaluate(fn(specType, i, parent));
              expect(store).toHaveLength(i + 1);
              expect(store[i].unit).toMatch(unitNameRegex(specType, i));
              await testRender(`${resolve}_${i}`);
            }

            await embed(spec(specType, 1, {type, resolve, encodings: ['x']}));
            for (let i = 0; i < hits[specType].length; i++) {
              const parent = parentSelector(specType, i);
              await page.evaluate(fn(specType, i, parent));
            }

            for (let i = hits[`${specType}_clear`].length - 1; i >= 0; i--) {
              const parent = parentSelector(specType, i);
              const store = await page.evaluate(fn(`${specType}_clear`, i, parent));
              expect(store).toHaveLength(i);
              if (i > 0) {
                expect(store[i - 1].unit).toMatch(unitNameRegex(specType, i - 1));
              }
              await testRender(`${resolve}_clear_${i}`);
            }
          });
开发者ID:vega,项目名称:vega-lite,代码行数:26,代码来源:resolve.test.ts


示例5: it

 it('changes password of current user', async () => {
     const $changepw = selector.form('#changepw-dialog');
     await page.click('#changepw');
     await page.waitForSelector($changepw.selector());
     await page.type($changepw.input('.newpass'), 'changed');
     await page.click($changepw.button('.change'));
 });
开发者ID:bradparks,项目名称:server,代码行数:7,代码来源:user.test.ts


示例6: it

    it('deletes own client', async () => {
        await page.click($table.cell(1, Col.Delete, '.delete'));

        // confirm delete
        await page.waitForSelector(selector.$confirmDialog.selector());
        await page.click(selector.$confirmDialog.button('.confirm'));
    });
开发者ID:bradparks,项目名称:server,代码行数:7,代码来源:client.test.ts


示例7: embed

  it('should brush over binned domains', async () => {
    await embed(
      spec(
        'unit',
        1,
        {type, encodings: ['y']},
        {
          x: {aggregate: 'count', type: 'quantitative'},
          y: {bin: true},
          color: {value: 'steelblue', field: null, type: null}
        }
      )
    );
    for (let i = 0; i < hits.bins.length; i++) {
      const store = await page.evaluate(brush('bins', i));
      expect(store).toHaveLength(1);
      expect(store[0].fields).toHaveLength(1);
      expect(store[0].values).toHaveLength(1);
      expect(store[0].fields[0].channel).toBe('y');
      expect(store[0].fields[0].field).toBe('b');
      expect(store[0].fields[0].type).toBe('R');
      expect(store[0].values[0]).toHaveLength(2);
      await testRender(`bins_${i}`);
    }

    const store = await page.evaluate(brush('bins_clear', 0));
    expect(store).toHaveLength(0);
  });
开发者ID:vega,项目名称:vega-lite,代码行数:28,代码来源:interval.test.ts


示例8: waitToDisappear

 it('changes password of jmattheis', async () => {
     await page.click($table.cell(3, Col.EditDelete, '.edit'));
     await page.waitForSelector($dialog.selector());
     await page.type($dialog.input('.password'), 'unicorn');
     await page.click($dialog.button('.save-create'));
     await waitToDisappear(page, $dialog.selector());
 });
开发者ID:bradparks,项目名称:server,代码行数:7,代码来源:user.test.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript puppeteer-core.Browser类代码示例发布时间:2022-05-25
下一篇:
TypeScript puppeteer.Browser类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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