Reputation: 11
Unable to locate the element in the table using protractor and bluebird promise concepts
HTML page - using angular JS:
<tr data-ng-repeat="tableRow in $ctrl.tableResults track by $index" id="case-list-table-row" class="ng-scope" style=""><!-- ngRepeat: tableTitle in $ctrl.tableTitles --><td data-ng-repeat="tableTitle in $ctrl.tableTitles" id="case-list-table-cell" class="ng-binding ng-scope">TFL7123631607</td><!-- end ngRepeat: tableTitle in $ctrl.tableTitles --><td data-ng-repeat="tableTitle in $ctrl.tableTitles" id="case-list-table-cell" class="ng-binding ng-scope">34</td><!-- end ngRepeat: tableTitle in $ctrl.tableTitles --><td data-ng-repeat="tableTitle in $ctrl.tableTitles" id="case-list-table-cell" class="ng-binding ng-scope">TFL</td><!-- end ngRepeat: tableTitle in $ctrl.tableTitles --><td data-ng-repeat="tableTitle in $ctrl.tableTitles" id="case-list-table-cell" class="ng-binding ng-scope">No Plea</td><!-- end ngRepeat: tableTitle in $ctrl.tableTitles -->
Code used to search and return the prose value:
this.searchIndex = function (myurn) {
return(()=> {
var my_table = element(by.css("case-list-table tbody tr"));
var td = my_table.element(by.css("td:first-child"));
element.all(td.each(function (element, index) {
element.getText().then(function (text) {
console.log("outer" + text);
console.log(index, text);
if (text.matches(myurn)) {
console.log("Inner" + text);
return promise.props({ index:index});
}
});
});
});
};
I am trying to find ID by looping though columns in the page and return index. So that I get individual filed element using index and then compare all the fields
Upvotes: 0
Views: 383
Reputation: 473833
From what I understand, case-list-table
is not a tag name but rather an id value of a table
element. Did not you mean:
table#case-list-table tbody tr
Also, you need to have return
s from all the promise nested levels:
this.searchIndex = function (myurn) {
return(()=> {
var my_table = element(by.css("table#case-list-table tbody tr"));
var td = my_table.element(by.css("td:first-child"));
return element.all(td.each(function (element, index) {
return element.getText().then(function (text) {
// ...
And, each()
is actually not quite appropriate here (I actually doubt the usage syntax is correct here at all). You are filtering the elements - use filter()
.
Upvotes: 1