Protractor 如何在量角器测试报告中添加自定义日志

Protractor 如何在量角器测试报告中添加自定义日志,protractor,report,Protractor,Report,我正在尝试将一些自定义日志添加到量角器测试报告中。我的项目文件夹中有一个应用程序日志文件,其中包含使用log4js捕获的日志。我希望这些日志条目也显示在我的测试报告中。目前我正在使用chercher report。因为我是量角器的初学者,我不知道怎么做。有人能帮我吗?提前谢谢 spec.js fdescribe('量角器Perfecto Demo',函数(){ })) conf.js var报告客户 exports.config={ //远程地址 //赛琳娜的裙子:'https://MY_HOS

我正在尝试将一些自定义日志添加到量角器测试报告中。我的项目文件夹中有一个应用程序日志文件,其中包含使用log4js捕获的日志。我希望这些日志条目也显示在我的测试报告中。目前我正在使用chercher report。因为我是量角器的初学者,我不知道怎么做。有人能帮我吗?提前谢谢

spec.js

fdescribe('量角器Perfecto Demo',函数(){

}))

conf.js

var报告客户

exports.config={ //远程地址
//赛琳娜的裙子:'https://MY_HOST.perfectomobile.com/nexperience/perfectomobile/wd/hub', directConnect:没错, //要传递给webdriver实例的功能。 能力:{ browserName:“chrome” //用户:“我的用户”, //密码:“我的通行证”, //平台名称:“Android”, //deviceName:'123456', },

}

运行此程序时,我发现以下错误:

一个错误最终被抛出 毕竟JavascriptError:javascript错误:未定义结束 (会话信息:chrome=90.0.4430.212)
(驱动程序信息:chromedriver=90.0.4430.24(4c6d850f087da467d926e8eddb76550aed655991参考/branch heads/4430@{429}),platform=Windows NT 10.0.19042 x8664)

我想在线上有很多关于这方面的教程。在堆栈溢出时,我们消除了人们的疑虑和问题。所以,让我们知道你到目前为止尝试了什么,以及你遇到了什么问题。所以我们可以帮你解决这个问题。我会在谷歌上搜索添加一个定制的Jasmine reporter。这些将在Jasmine runner启动之前被注入插件。@KSK,添加了我迄今为止尝试过的东西的更多细节。
it('should pass test', function () {
  browser.reportingClient.stepStart('Step 1: Navigate Google');
  browser.driver.get('https://www.google.com'); //Navigate to google.com
  browser.reportingClient.stepEnd();
  //Locate the search box element and insert text
  //Click on search button
  browser.reportingClient.stepStart('Step 2: Send Keys');
  browser.driver.findElement(by.name('q')).sendKeys('PerfectoCode GitHub');
  browser.reportingClient.stepEnd();
  browser.reportingClient.stepStart('Step 3: Click');
  browser.driver.findElement(by.css('#tsbb > div')).click();
  browser.reportingClient.stepEnd();

});

//This test should fail
it('should fail test', function () {
  browser.reportingClient.stepStart('Step 1: Navigate Google');
  browser.driver.get('https://www.google.com'); //Navigate to google.com
  browser.reportingClient.stepEnd();
  //Locate the search box element and insert text
  //Click on search button
  browser.reportingClient.stepStart('Step 2: Send Keys');
  browser.driver.findElement(by.name('q')).sendKeys('PerfectoCode GitHub');
  browser.reportingClient.stepEnd();
  browser.reportingClient.stepStart('Step 3: Click');
  browser.driver.findElement(by.css('#tsbbbsdasd > div')).click();
  browser.reportingClient.stepEnd();
});

  afterAll(function(done){
      
      process.nextTick(done); 
  });
//Framework to use. Jasmine is recommended.
framework: 'jasmine',

// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['./tests/SignupAutomation_spec.js'],

// Options to be passed to Jasmine.
jasmineNodeOpts: {
    showColors: true,   // Use colors in the command line report.   
    defaultTimeoutInterval: 120000  // Time to wait in ms before a test fails. Default value = 30000
},

onComplete: function () {
    // Output report URL
    return reportingClient.getReportUrl().then(
        function (url) {
            console.log(`Report url = ${url}`);
        }
    );
},

onPrepare: function () {
    const Reporting = require('perfecto-reporting');

    reportingClient = new Reporting.Perfecto.PerfectoReportingClient(new Reporting.Perfecto.PerfectoExecutionContext({
        webdriver: browser.driver,
        tags: ['javascript driver']
    }));
    browser.reportingClient = reportingClient;

    var myReporter = {
        specStarted: function (result) {
            reportingClient.testStart(result.fullName);
        },
        specDone: function (result) {
            if (result.status === 'failed') {
                const failure = result.failedExpectations[result.failedExpectations.length - 1];
                reportingClient.testStop({
                    status: Reporting.Constants.results.failed,
                    message: `${failure.message} ${failure.stack}`
                });
            } else {
                reportingClient.testStop({
                    status: Reporting.Constants.results.passed
                });
            }
        }
    }

    jasmine.getEnv().addReporter(myReporter);
}