我正在自动化一个场景,在这个场景中,我得到的元素列表将它存储在一个数组中,我需要从数组中删除重复的单词“teniss”。
直到我能够获取元素&试图使用if条件来实现它。
var lists=element.all(By.css(".entity-link>a"));
lists.getText().then(function(text){
console.log("The list contents are "+text);
}
for (var i=0; i<40;){
if (lists.get(i) === 'teniss')
{
lists.get(i)=="";
}
i++;
}
输出地图功能:
[ { index: 0, text: 'teniss' },
{ index: 1, text: 'ARTICLE 1' },
{ index: 2, text: 'teniss' },
{ index: 3, text: 'ARTICLE 2' },
{ index: 4, text: 'teniss' },
{ index: 5, text: 'ARTICLE 3' },
{ index: 6, text: 'teniss' },
{ index: 7, text: 'ARTICLE 4' },
{ index: 8, text: 'teniss' },
{ index: 9, text: 'ARTICLE 5' },
{ index: 10, text: 'teniss' },
{ index: 11, text: 'ARTICLE 6' },
{ index: 12, text: 'teniss' },
{ index: 13, text: 'ARTICLE 7' },
{ index: 14, text: 'teniss' },
{ index: 15, text: 'ARTICLE 8' },
{ index: 16, text: 'teniss' },
{ index: 17, text: 'ARTICLE 9' },
{ index: 18, text: 'teniss' },
{ index: 19, text: 'ARTICLE 10' },
{ index: 20, text: 'teniss' },
{ index: 21, text: 'ARTICLE 11' },
{ index: 22, text: 'teniss' },
{ index: 23, text: 'ARTICLE 12' },
{ index: 24, text: 'teniss' },
{ index: 25, text: 'ARTICLE 13' },
{ index: 26, text: 'teniss' },
{ index: 27, text: 'ARTICLE 14' },
{ index: 28, text: 'teniss' },
{ index: 29, text: 'ARTICLE 15' },
{ index: 30, text: 'teniss' },
{ index: 31, text: 'ARTICLE 16' },
{ index: 32, text: 'teniss' },
{ index: 33, text: 'ARTICLE 17' },
{ index: 34, text: 'teniss' },
{ index: 35, text: 'ARTICLE 18' },
{ index: 36, text: 'teniss' },
{ index: 37, text: 'teniss' },
{ index: 38, text: 'teniss' } ]