protractor-jasmine2-screenshot-reporter不在所需文件夹中生成屏幕截图 [英] protractor-jasmine2-screenshot-reporter not generating screenshots in the required folder

查看:258
本文介绍了protractor-jasmine2-screenshot-reporter不在所需文件夹中生成屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的protractor.conf.js具有以下内容。我无法在这里发现什么是错的。我在angular-cli的根文件夹中手动创建了目标/屏幕截图。当我运行量角器conf.js时,量角器会在浏览器窗口中测试,但屏幕截图没有生成。任何人都可以帮我解决这个问题吗?

My protractor.conf.js has the following content. I was unable to find out whats wrong here. I have manually created target/screenshots in my root folder of angular-cli. When i run protractor conf.js the protractor tests in browser window but the screenshots aren't being generated. Can anyone help me resolve this?

// Protractor configuration file

const { SpecReporter } = require('jasmine-spec-reporter');
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var fs = require('fs');

var reporter = new HtmlScreenshotReporter({
  dest: 'target/screenshots',
  filename: 'my-report.html',
  cleanDestination: false,
  showSummary: true,
  showConfiguration: false,
  reportTitle: null,
  ignoreSkippedSpecs: false,
  captureOnlyFailedSpecs: false,
  reportOnlyFailedSpecs: false
});

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: false,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  chromeOnly: true,
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js'],
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(reporter);  
  },
  afterLaunch: function(exitCode) {
    return new Promise(function(resolve){
      reporter.afterLaunch(resolve.bind(this, exitCode));
    });
  }
};

提前致谢!

推荐答案

protractor-jasmine2-screenshot-reporter jasmine2 兼容,因此更改为框架:你的conf.js中的'jasmine2'

protractor-jasmine2-screenshot-reporter compatible with jasmine2, so change to framework: 'jasmine2' in your conf.js

你需要使用更高版本的量角器其中包括 jasmine2

And you need to use higher version of Protractor which includes jasmine2

我用你的conf进行了快速测试(做的很少)变化)并且有效。

I did a quick test with your conf(did little changes) and it worked.

conf.js

var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
// var fs = require('fs');

var reporter = new HtmlScreenshotReporter({
  dest: 'target/screenshots',
  filename: 'my-report.html',
  cleanDestination: false,
  showSummary: true,
  showConfiguration: false,
  reportTitle: null,
  ignoreSkippedSpecs: false,
  captureOnlyFailedSpecs: false,
  reportOnlyFailedSpecs: false
});

exports.config = {
  allScriptsTimeout: 11000,
//   specs: [
//     './e2e/**/*.e2e-spec.ts'
//   ],
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: false,
//   baseUrl: 'http://localhost:4200/',
  framework: 'jasmine2',
//   chromeOnly: true,
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js'],
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    jasmine.getEnv().addReporter(reporter);  
  },
  afterLaunch: function(exitCode) {
    return new Promise(function(resolve){
      reporter.afterLaunch(resolve.bind(this, exitCode));
    });
  }
};

spec.js

   describe('xxx', function(){

        it('yyy', function(){

            browser.get('https://angular.io/');
        });
    });

目标/屏幕截图文件夹和 HTML 报告,
(我跑两次,所以有两个截图。)

target/screenshots folder and HTML report, (I run for twice, so there are two screenshots.)


  • 点击 yyy 将打开屏幕截图

  • protractor-jasmine2-screenshot-reporter 将创建 target / screenshots 文件夹如果不存在,则无需提前创建。

  • click the yyy will open the screenshot
  • protractor-jasmine2-screenshot-reporter will create target/screenshots folder if not exist, no need to create in advance.

我使用的版本

protractor 5.3.0
protractor-jasmine2-screenshot-reporter  0.5.0

这篇关于protractor-jasmine2-screenshot-reporter不在所需文件夹中生成屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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