A bit new to javascript, but from what I've read, all values within a promise are basically only usable within that promise right?
Basically getSomething() returns true/false from another promise. And I was to break out of the for loop if true. I tried something like this, but I'm sure it's not right as it's not printing out "breaking"
for(...) {
var bool = this.getSomething(a,b,c).then((flag) => {
if (flag == true) {
console.log('returning true');
return true; // can't use break so have to set boolean - eslint gives me unsyntactical break
}
});
if (bool == true) {
console.log('breaking');
break;
}
}
getSomething(a,b,c) {
const n = b[a].element(by.binding('something'));
return n.getText().then((text) => {
if (text === c) {
return clickSomething(); // returns true after click()
}
});
}
The reason I'm using the for loop is because I need to find a matching text in the strong tag, then click on the button in the td tag below it.
<tbody>
<tr ng-repeat="something">
<td>
<strong>{{x.name}}</strong>
</td>
<td>
<button>{{x.button}}</button>
</td>
</tr>
</tbody>