我正在尝试通过量角器测试ng-repeat(ed)表的最后一行来测试并确保刚刚在之前的测试运行中创建的对象出现。我已经得到尽可能多的行的文本,但似乎无法通过反复试验找出如何将最后一行的每一列作为数组的一部分,以便我可以验证每一段,然后在最后一列我有按钮来点击下一步。AngularJS e2e使用量角器测试
我到目前为止的代码是:
var elems = element.all(by.repeater('alert in alerts'));
elems.last().then(function(elm) {
console.log(expect(elm.getText()).toMatch('/testRunner/'));
});
如上所述,预期输出/输出我要核对是“textRunner”,而是我得到整个文本行作为这样的:
testRunner testing the runner 5 minutes No View Edit Enable
编辑 这里是我的最终代码:
var rows = element.all(by.repeater('alert in alerts'));
rows.last().then(function(row) {
var rowElems = row.findElements(by.tagName('td'));
rowElems.then(function(cols){
expect(cols[0].getText()).toContain('testRunner');
expect(cols[1].getText()).toContain('testing the runner');
expect(cols[4].getText()).toContain('5 minutes');
});
});
当我用你的代码中,我得到正确的列,但不正确的行,我只得到了第一行不是最后一次。有没有一种计数行并使用它的方法? – Brian
我的代码中存在一个错误。我使用元素而不是榆树。为了清晰起见,我更改了变量名称。 – gontard
我得到一个TypeError:Object [object Object]没有方法'all'error – Brian