2016-11-22 3 views
2

테스트에서 먼저 특정 제품을 찾아서 해당 제품의 일부 하위 요소에 대한 작업을 수행해야합니다. 많은 제품이 있습니다.각도기 : 요소의 요소를 찾을 수 없습니다.

이것은 내 첫 번째 분도기 스크립트이므로 나와 함께 곰.

var prod = element.all(by.css('singleproduct')).get(1); 

singleproduct은 지침입니다. 이 중단 스크립트의 일부입니다

<singleproduct ng-repeat="item in vm.products" item="::item" class="col-xs-12 col-sm-6 col-md-4 product_tile ng-scope ng-isolate-scope"> 
    <article ng-class="{'product--active': isSelected}" class="product"> 
     <section ng-click="toggleDetails()" class="product-content"> 
     <!-- some prod info --> 
     </section> 
     <section>    
     <div class="product-ordering"> 
      <ul class="product-quantities"> 
       <!-- ngRepeat: option in ::priceList --> 
       <li ng-repeat="option in ::priceList" class="ng-scope"> 
        <!-- this is the LI I want to catch... 
       </li> 
       <!-- end ngRepeat: option in ::priceList --> 
       <li ng-repeat="option in ::priceList" class="ng-scope"> 
        <!-- this is the LI I want to catch... 

       </li> 
       <!-- end ngRepeat: option in ::priceList --> 
       <li ng-repeat="option in ::priceList" class="ng-scope"> 
        <!-- this is the LI I want to catch... 
       </li> 
       <!-- end ngRepeat: option in ::priceList --> 
      </ul> 
     </div> 
     </section> 
    </article> 
</singleproduct> 
+2

당신이있어 니스 문제는, 그것은 github의 문제를, 그것을위한 새로운 eslint 규칙을 추가 따르도록 영감을 관심이있는 경우 : https://github.com/alecxe/eslint-plugin-protractor/issues/57 . 감사. – alecxe

+0

@alecxe 플러그인이 있다는 것을 몰랐습니다. 매우 유용합니다! – faboolous

+0

저는 바보입니다.이 규칙을 구현 한 것으로 알고 있습니다. https://github.com/alecxe/eslint-plugin-protractor/blob/master/docs/rules/no-array-finder-methods를 참조하십시오. .md. 감사. – alecxe

답변

3

each() 함수는 배열 작동합니다 : 난 항상 element(...).each is not a function

HTML을 얻을, 그러나

prod.element(by.css(".product-ordering ul li")).each(function(elem) { 

}) 

. prod.element(by.css(".product-ordering ul li"))은 이 아니라 ElementFinder을 반환합니다. product.element() 대신 product.all()을 사용해야합니다. 아래의 예를보십시오.

prod.all(by.css(".product-ordering ul li")).each(function(elem) { 

}) 
+0

나는 방금 알아 낸 것처럼 내 자신의 질문에 대답하려고했습니다. 고맙습니다! – faboolous

관련 문제