Reputation: 214
I want to select Records from the list box and save the page. Once saved the Selected Records will be populated in the top of the list. Records which are not selected will be displayed below the selected records list.
Below is the Element for Non Selected Records
<li ng-class="{'list-group-item-info': agent.$selected}" ng-repeat="agent in newAgents" style="padding: 5px 15px;" class="list-group-item ng-binding ng-scope" ng-click="toggleSelection(0, 'newAgent')"><span ng-show="agent.$selected" class="label label-success ng-hide"><small><span class="glyphicon glyphicon-ok"></span></small></span> Anto</li>
<li ng-class="{'list-group-item-info': agent.$selected}" ng-repeat="agent in newAgents" style="padding: 5px 15px;" class="list-group-item ng-binding ng-scope" ng-click="toggleSelection(1, 'newAgent')"><span ng-show="agent.$selected" class="label label-success ng-hide"><small><span class="glyphicon glyphicon-ok"></span></small></span> LokeshMahalingam</li>
This is HTML Element for Selected Record
<li ng-class="{'list-group-item-danger': agent.$selected}" ng-repeat="agent in agents" style="padding: 5px 15px;" class="list-group-item-success ng-binding ng-scope" ng-click="toggleSelection(0, 'agent')"><span ng-show="agent.$selected" class="label label-danger ng-hide"><small><span class="glyphicon glyphicon-remove"></span></small></span>Christopher</li>
Code is what i am using now. (This code only selects the first record whether it is selected already or not)
this.SkillAgent = element(by.css('li[ng-repeat="agent in newAgents"]'));
I also tried the below code but not working
this.SkillAgent = element(by.css('li[ng-click="toggleSelection(0, newAgent)"]'));
Upvotes: 2
Views: 337
Reputation: 214
I was able to select the value in the list box via get function. 1,2... are row of data's in the list box.
this.SkillAgent1 = element.all(by.repeater("agent in newAgents")).get(1);
this.SkillAgent2 = element.all(by.repeater("agent in newAgents")).get(2);
Upvotes: 1
Reputation: 473833
First of all, there is a relevant by.repeater()
locator:
this.SkillAgent = element.all(by.repeater("agent in newAgents"));
To identify the selected elements, we may use filter()
function with evaluate()
to evaluate the value of agent.$selected
:
this.selectedAgents = this.SkillAgent.filter(function (agent) {
return agent.evaluate("agent.$selected").then(function (isSelected) {
return isSelected;
});
}):
Or, alternatively, check the presence of list-group-item-danger
class:
this.selectedAgents = $$("li.list-group-item-danger");
Upvotes: 2