In my angular app, I have a timeline feature that displays the names and descriptions of players. All player names are under the common class player-title.ng-binding
, while all player descriptions share the class .player-description.ng-binding
To retrieve the names and descriptions, I used the following code:
element.all(by.css('.player-title.ng-binding')).getText().then(function(name){
//prints name of first player
console.log(name[0]);
});
element.all(by.css('.player-description.ng-binding')).getText().then(function(description){
//prints description of first player
console.log(description[0]);
});
However, I'm struggling to verify that each player has the correct description. For example, using
expect(name[0]).toEqual(description[0]);
. I'm new to promises and would appreciate any advice on this issue.
Additionally, when I tried the following code, it printed undefined:
var name = element.all(by.css('.player-title.ng-binding')).getText().then(function(name){
});
console.log(name[0]);
Below is the HTML code for displaying players:
<!-- player -->
<h4 class="font-thin m-t-lg m-b-lg text-primary-lt">Sponsor player</h4>
<p></p>
<div class="player m-l-sm m-r-sm b-info b-l">
<div ng-repeat = "player in formattedplayerData | orderBy : '-Name'">
<div class = "tl-item">
<i class="pull-left player-badge {{player.class}} "></i>
<div class="m-l-lg">
<div class="player-title">{{player.Name}}</div>
<p class="player-description">{{player.description}}</p>
</div>
</div>
</div>
</div>
<!-- / player -->
Any insights or suggestions on this topic would be greatly appreciated.