Answer the question
In order to leave comments, you need to log in
How to get out of a for loop?
How to exit a loop when a condition is met?
for(let i = 0; i < elements.length; i++){
elements[i].findElement(by.xpath('.//span')).getAttribute('innerText').then(function(text){
if(~'Бадминтон'.indexOf(text)){
console.log(text);
// Выход из цикла перебора
};
});
};
Answer the question
In order to leave comments, you need to log in
async function
for...of
(async () => {
// ...
for(const element of elements) {
const text = await element.findElement(by.xpath('.//span')).getAttribute('innerText');
if(~'Бадминтон'.indexOf(text)) {
console.log(text);
break;
}
}
// ...
})()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question