以下方法是传递数据表而不执行断言,因为它没有断言任何内容,它会自动通过黄瓜步骤。
Then(/^the following <fields> are displayed in the Method Information panel$/, (table) => {
var hashes = table.hashes();
var expectedValues: string[] = new Array();
return hashes.forEach(function (hash) {
console.log("In For Each");
expectedValues.push(hash.fields);
var index = expectedValues.length - 1;
console.log(expectedValues[index])
expectedValues[index] = expectedValues[index].replace(' ', '');
return element(by.id("label" + expectedValues[index])).getText()
.then(function (actualValues) {
console.log("In Then:" + actualValues);
report.takeScreenshot();
return expecting(actualValues).to.deeply.equal(expectedValues[index]);
}, function (err) {
report.logError("An error occurred while comparing values." + err);
});
}, function (err) {
report.logError("An error occurred while comparing values." + err);
});
});
控制台日志如下所示:
In For Each
Name
In For Each
Description
In For Each
Type
In For Each
Instrument System
√ Then the following <fields> are displayed in the Method Information panel
| fields |
| Name |
| Description |
| Type |
| Instrument System |
答案 0 :(得分:0)
如果你删除了该行的回报:
return element(by.id("label" + expectedValues[index])).getText()
它会继续吗?
我不熟悉TypeScript,但是你还需要在哈希上使用return吗?
return hashes.forEach(function (hash) {
而不是getText,你有什么用
getAttribute('textContent')
或
getAttribute('value')