找不到元素的元素

问题描述 投票:2回答:1

在我的测试中,我需要找到一个具体的产品,然后做该产品的一些子元素一些操作。有很多产品。

这是我的第一个量角器脚本,以便和我一起承担。

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>
javascript angularjs protractor
1个回答
3
投票

each()功能将只用数组。但prod.element(by.css(".product-ordering ul li"))将返回一个ElementFinder而不是ElementArrayFinder。您需要改用product.all()product.element()。请看下面的例子。

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

}) 
© www.soinside.com 2019 - 2024. All rights reserved.