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