【发布时间】:2016-06-23 07:27:58
【问题描述】:
我是第一次使用 Protractor,我已经为 protractor、protractor-trx-reporter、jasmine-trx-reporter 和 webdriver-manager 安装了一些带有 NPM 的模块。 Selenium 服务器在默认的 4444 端口上运行,当我通过命令行在本地运行它时,测试似乎运行良好(打开浏览器,测试通过)。
一切似乎都没有报错,但是我找不到protractor-trx-reporter发布的trx文件。当我运行protractor conf.js 时,测试开始,命令行输出显示它正在导出 trx 报告器并将输出文件设置为 ProtractorTestResults.trx 但 .trx 文件没有出现在任何地方,所以我怀疑它没有发布文件但不抛出错误。
如果 protractor-trx-reporter 没有导出 trx 文件有什么想法吗?
这是我的配置和规范文件的样子(均取自 Protractor 和 protractor-trx-reporter 网站的样本)
//conf.js
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
onPrepare: function () {
console.log('Adding TRX reporter');
require('protractor-trx-reporter');
jasmine.getEnv().addReporter(new jasmine.TrxReporter('ProtractorTestResults.trx'));
}
}
//spec.js
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write first protractor test');
// You wrote your first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});
【问题讨论】:
-
这个好运吗,我也有类似的问题?
-
我实际上最终放弃了 protractor-trx-reporter 并切换到 jasmine-trx-reporter npmjs.com/package/jasmine-trx-reporter,并且效果很好。 :(
-
@Sachi 我不断收到 jasmine-trx-reporter 的 trx is not defined 错误。
-
@Defpotec2020 添加了我自己的关于我如何运行它的答案,这应该可以帮助你。
-
@sachi,我寄予厚望。当我在 groupSuitesIntoSingleFile 设置为 false 的情况下运行它时,我现在得到“找不到规范”。当我在 groupSuitesIntoSingleFile 设置为 true 的情况下运行它时出现 trx not found 错误。两种情况都没有报告。当我完全删除您的代码时,一切都运行良好(当然没有生成报告)。关于什么可能是错的任何想法?谢谢!
标签: angularjs protractor