Я написал некоторый код для поиска индекса элемента путем сравнения текста в транспортире с использованием Javascript:
this.getIndexOfRootProject = function(){
return element(by.className('menu__link_label')).then(function(labels){
console.log('The number of the menu labels are '+labels.length);
for(let i =0; i<labels.length; i++){
return labels[i].getText().then(function(text){
console.log('Text in the menu labels is '+text)
if(text.indexOf("CreditCardApplication")!== -1){
console.log('The rootProjectIndex is '+rootProjectIndex);
this.rootProjectIndex = i;
return this.rootProjectIndex;
}
})
}
})
}
Я вызываю функцию в моем файле спецификаций как функцию обратного вызова.
webstudioWS.clickOnAllProject().then(function(){
console.log( 'I am inception');
webstudioWS.getIndexOfRootProject();
})
При запуске скрипта я получаю эту ошибку:
Message:
Failed: element(...).then is not a function
Stack:
TypeError: element(...).then is not a function