2017-05-24 2 views
0

내 응용 프로그램에는 몇 개의 행이 있으며 각 행의 마지막 열에 '편집'| '삭제'옵션이 있습니다. 우리가 '업데이트'에 대한 옵션을 얻을 같은 장소에서 편집을 클릭 |, 나는 성공적으로 편집 클릭 몇 가지 변경을 내가 업데이 트를 클릭 할 때이 오류가 발생합니다 '취소'각도기 - 로케이터에 대해 하나 이상의 요소가 있습니다. by.css (.....)

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> 

업데이트 링크를 클릭하는 방법을 알려주세요.

답변

3
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. 
}); 
+0

감사합니다.하지만 이름 (첫 번째 열)을 기준으로 행을 식별하고 수정을 클릭하여 필드의 일부 변경을 수행하고 업데이트를 클릭하십시오. 편집을 클릭하면 요소를 사용했습니다. element.all (by.repeater ("list in biometricsList")) filter (function (_tableRow) { return _tableRow.element (by.css ("td : nth-child (첫 번째 요소 (by.css ("i.fa-pencil-1"))).). 이 특정 행의 업데이트 링크를 클릭해야합니다. –

+0

인라인 편집을 수행하는 경우 편집중인 현재 행에서만 볼 수있는 '업데이트'버튼이 대부분입니다. linkText 선택자를 사용해 보시지 않겠습니까? 요소 (by.linkText ('Update')) 또는 요소 (by.partialLinkTex ('Update')) – BKS

1

각 클릭 사이에 sleep을 추가하십시오. 이것은 분도기가 별도로 링크를 이해하는 데 도움이 될 수 있습니다.

browser.sleep(2000);