admin管理员组

文章数量:1406008

In my application there are couple of rows and in each row last column, there is option of 'Edit'|'Delete' and when click on Edit, on the same place we get option for 'Update'|'Cancel', I successfully clicked on edit, made some changes and when I try to click on update it throws an error:

more than one element found with locator by.css(..) as both have same code

<td>
<div class="biometricActionCln ng-hide" ng-show="!list.isEditable" style="">
<a ng-click="editBiometrics(list, $index)">
**<i class="fa fa-pencil-square-o">**
</i> Edit</a>
<span> | </span>
<div ng-show="list.isEditable" class="" style="">
<a ng-click="manageEditBiometric(editBiometric, 'Modify', list.biometricId)">
**<i class="fa fa-pencil-square-o">**
</i> Update</a>
<span> | </span>
</div>
</td>

Kindly let me know how do I click on update link.

In my application there are couple of rows and in each row last column, there is option of 'Edit'|'Delete' and when click on Edit, on the same place we get option for 'Update'|'Cancel', I successfully clicked on edit, made some changes and when I try to click on update it throws an error:

more than one element found with locator by.css(..) as both have same code

<td>
<div class="biometricActionCln ng-hide" ng-show="!list.isEditable" style="">
<a ng-click="editBiometrics(list, $index)">
**<i class="fa fa-pencil-square-o">**
</i> Edit</a>
<span> | </span>
<div ng-show="list.isEditable" class="" style="">
<a ng-click="manageEditBiometric(editBiometric, 'Modify', list.biometricId)">
**<i class="fa fa-pencil-square-o">**
</i> Update</a>
<span> | </span>
</div>
</td>

Kindly let me know how do I click on update link.

Share Improve this question edited May 24, 2017 at 12:15 alecxe 475k127 gold badges1.1k silver badges1.2k bronze badges asked May 24, 2017 at 6:24 Hema LathaHema Latha 851 gold badge3 silver badges12 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5
Below are different ways of handling multiple elements.

accessing multiple elements with index:
element.all(by.css('.selector'))[0]
element.all(by.css('.selector'))[1]

accessing multiple elements by calling methods:
element.all(locator).first();
element.all(locator).last();

accessing multiple elements through callback function:
element.all(by.css('.selector')).then(function(elements) {
  // elements is an array of ElementFinders.
});

本文标签: javascriptProtractormore than one element found for locator bycss()Stack Overflow