【发布时间】:2021-06-22 09:27:37
【问题描述】:
我想检查应用程序返回的列表是否包含预期的元素。请告诉我哪里出错了:
this.verifyOptionsInDrpDwn = async function(){
var optionList = await drpDwn.all(by.tagName('option')).getText();
console.log(optionList);
var expOptions=['a','b','c','d','e','f'];
for (let i = 0; i < expOptions.length; i++) {
var bool=optionList.includes(expOptions[i]);
console.log(bool);
}
}
output :
[
'1-a',
'2-b',
'3-c',
'4-d',
'5-e',
'6-f'
]
false
【问题讨论】:
-
你的 optionList 数组是 [ '1-a', '2-b', '3-c', '4-d', '5-e', '6-f' ] 因此这不是预期的输出吗?我不确定你在问什么?
-
是的,您的输出示例令人困惑
-
在实际列表中,它有'1-a'(例如),但我只想验证'a'是否存在。
标签: javascript node.js angularjs selenium protractor