量角器在失败时捕获截图 [英] Protractor capture screenshot on failure

查看:69
本文介绍了量角器在失败时捕获截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 afterEach 方法中编写了以下代码,以捕获失败上的屏幕截图

I have written below code in afterEach method to capture screenshot on failure

afterEach(function() {
  var passed = jasmine.getEnv().currentSpec.results().passed();
  if (!passed) {
    browser.takeScreenshot().then(function(png) {
      //capturing screenshot here

    };
  }
});

但执行时遇到错误..

But while executing getting below error..

 Message:
   Failed: Cannot read property 'results' of undefined
 Stack:
   TypeError: Cannot read property 'results' of undefined

如何删除上述错误......

how to remove above error...

推荐答案

currentSpec 无法开始工作 jasmine2

请查看 protractor-jasmine2-screenshot-reporter 适合您的使用案例。

Please see if protractor-jasmine2-screenshot-reporter fits your use case.

还有 jasmine-test-container-支持扩展jasmine2的 库,并为您提供有关当前执行测试所需的所有元信息。

There is also jasmine-test-container-support library that extends jasmine2 and provides you with all of the meta information you would need about the currently executed test.

这篇关于量角器在失败时捕获截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆