2016-11-22 3 views
2

私のテストでは、最初に特定の製品を見つけて、その製品のいくつかのサブ要素にいくつかの操作を行う必要があります。多くの製品があります。分度器:要素の要素を見つけることができません

これは私の最初の分度器のスクリプトですので、私に同行してください。

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

singleproductディレクティブです。 これは壊れたスクリプトの一部です:

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

}) 

しかし、私はいつもelement(...).each is not a function

HTML取得:

<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()を関数は配列でのみ動作します。 prod.element(by.css(".product-ordering ul li"))ElementFinderで、ElementArrayFinderではありません。 product.element()の代わりにproduct.all()を使用する必要があります。下の例を見てください。あなたが持っている

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

}) 
+0

ちょうど私が知ったように私は自分の質問に答えようとしていた。ありがとうございました! – faboolous

関連する問題