【发布时间】:2015-05-10 18:03:57
【问题描述】:
我想使用 Lodash find 函数使我的 Protractor 测试更加稳健。
代替
element.all (by.repeater ('topic in topics')).then (function (topics) {
expect (topics[1].element (by.binding ('topic.name')).getText()).toEqual ('Maths');
expect (topics[1].element (by.binding ('topic.description')).getText()).toEqual ('2 + 2 = 4');
});
类似
element.all (by.repeater ('topic in topics')).then (function (topics) {
var mathsTopic = _.find (topics, 'topic.name', 'Maths');
expect (mathsTopic.element (by.binding ('topic.description')).getText()).toEqual ('2 + 2 = 4');
});
我的理由是,如果页面中项目的顺序发生变化,测试不会中断,因为它仍然可以找到包含它正在寻找的数据的元素。
【问题讨论】:
标签: angularjs node.js protractor lodash