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


TypeScript browser.takeScreenshot方法代码示例

本文整理汇总了TypeScript中protractor.browser.takeScreenshot方法的典型用法代码示例。如果您正苦于以下问题:TypeScript browser.takeScreenshot方法的具体用法?TypeScript browser.takeScreenshot怎么用?TypeScript browser.takeScreenshot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在protractor.browser的用法示例。


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

示例1: writeScreenshot

export async function writeScreenshot(filename: string) {
  let png = await browser.takeScreenshot();
  let stream = fs.createWriteStream(filename);
  stream.write(new Buffer(png, 'base64'));
  stream.end();
  info(`Saved screenshot to: ${filename}`);
}
开发者ID:joshuawilson,项目名称:almighty-ui,代码行数:7,代码来源:core.ts

示例2: After

After(async function(scenario) {
    if (scenario.result.status === Status.FAILED) {
        // screenShot is a base-64 encoded PNG
         const screenShot = await browser.takeScreenshot();
         this.attach(screenShot, "image/png");
    }
});
开发者ID:alexrun,项目名称:protractor-cucumber-typescript,代码行数:7,代码来源:hooks.ts

示例3: takeScreenShot

export function takeScreenShot(fileName?: string, pathName?: string) {
    const pathNameFinal = pathName || './e2e/screenshots';
    const fileNameFinal = fileName || Date.now().toString();
    browser.takeScreenshot()
        .then((png) => {
            const file = path.resolve(path.join(pathNameFinal, fileNameFinal + '.png'));
            fs.writeFileSync(file, png, { encoding: 'base64' });
        });
}
开发者ID:rlasjunies,项目名称:kct,代码行数:9,代码来源:_helper.ts

示例4: function

 this.specDone = function (result) {
     if (result.failedExpectations.length > 0) {
         browser.takeScreenshot().then(function (png) {
             var stream = fs.createWriteStream(`e2e/error-${result.description}.png`);
             stream.write(new Buffer(png, 'base64'));
             stream.end();
         });
     }
 };
开发者ID:keviocastro,项目名称:daily-ui,代码行数:9,代码来源:shared.e2e.ts

示例5: Buffer

 this.After((scenario, done) => {
   if (scenario.isFailed()) {
     return browser.takeScreenshot().then(function (base64png) {
       let decodedImage = new Buffer(base64png, 'base64').toString('binary');
       scenario.attach(decodedImage, 'image/png');
     }, (err) => {
       done(err);
     });
   } else {
     done();
   }
 });
开发者ID:cnishina,项目名称:protractor-cookbook,代码行数:12,代码来源:hooks.ts

示例6: takeScreenshot

export async function takeScreenshot(name: string) {
  await changeAppleSysFont();
  const config = await browser.getProcessedConfig();
  const deviceName = config['capabilities'].name;
  // gets set when debugging in a single instance
  const device = deviceName ? deviceName : 'debug';
  const pngData = await browser.takeScreenshot();
  const path = join(dir, `${name}_${device}.png`);
  writeFile(path, pngData, { encoding: 'base64' }, err => {
    // tslint:disable-next-line:no-console
    err ? console.error(err) : console.log(`File written: ${path}`);
  });
}
开发者ID:bitjson,项目名称:copay,代码行数:13,代码来源:utils.ts

示例7: afterEach

    /**
     * An example 'after' hook that will be run after every scenario.
     */
    @after()
    private async afterEach(scenario: HookScenarioResult) {
        let success = scenario.result.status === Status.PASSED ? 'successfully' : 'unsuccessfully';
        console.log(`The scenario '${scenario.pickle.name}' has completed ${success}`);

        // Taking a screenshot of the browser if the scenario has failed.
        if (scenario.result.status === Status.FAILED) {
            let screenshot = await browser.takeScreenshot();
            let browserName = (await browser.getCapabilities()).get('browserName');
            let filename = browserName + ' FAIL - ' + scenario.pickle.name + '.png';

            Utils.writeScreenshot(screenshot, filename) 
        }
    }
开发者ID:akotsar,项目名称:cucumber-protractor-test-seed,代码行数:17,代码来源:hooks.ts

示例8:

browser.enterRepl(0, 0);
browser.enterRepl('1');
browser.enterRepl(true);
browser.enterRepl(() => {});
browser.pause(0, 0);
browser.pause('1');
browser.pause(true);
browser.pause(() => {});
browser.actions(0);
browser.actions('1');
browser.actions(true);
browser.actions(() => {});
browser.wait('condition', '1');
browser.wait('condition', true);
browser.wait('condition', () => {});
browser.wait('condition', 100, 0);
browser.wait('condition', 100, true);
browser.wait('condition', 100, () => {});
browser.getCurrentUrl(0);
browser.getCurrentUrl('1');
browser.getCurrentUrl(true);
browser.getCurrentUrl(() => {});
browser.getTitle(0);
browser.getTitle('1');
browser.getTitle(true);
browser.getTitle(() => {});
browser.takeScreenshot(0);
browser.takeScreenshot('1');
browser.takeScreenshot(true);
browser.takeScreenshot(() => {});
开发者ID:HelloMQL,项目名称:protractor,代码行数:30,代码来源:test_fail_browser.ts

示例9: constructor

 constructor(id: string) {
   this.id = `${currentJasmineSpecName} ${id}`;
   browser.takeScreenshot().then(png => this.storeScreenshot(png));
 }
开发者ID:dominikstrasser,项目名称:material2,代码行数:4,代码来源:screenshot.ts

示例10: async

 let createScreenshot = async(): string => {
     let data = await browser.takeScreenshot();
     let path = fs.writeFileSync('./e2e/screenshot.png', data, 'base64');
     console.log('CREATED SCREENSHOT: ', path);
     return path;
 }
开发者ID:alcfeoh,项目名称:ng2-weather,代码行数:6,代码来源:app.e2e-spec.ts


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