Protractor capture screenshot on failure

痞子三分冷 提交于 2019-12-23 05:42:09

问题


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...


回答1:


currentSpec is not going to work with jasmine2.

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

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.



来源:https://stackoverflow.com/questions/34393988/protractor-capture-screenshot-on-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!