Reputation: 6320
In my tests, I need to first find a specific product, and then do some operations on some subelements of that product. There are many products.
This is my first protractor scripts so bear with me.
var prod = element.all(by.css('singleproduct')).get(1);
singleproduct
is a directive.
This is the part of the scripts which breaks:
prod.element(by.css(".product-ordering ul li")).each(function(elem) {
})
However, I always get 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>
Upvotes: 2
Views: 338
Reputation: 4832
each()
function will work only with array. but prod.element(by.css(".product-ordering ul li"))
will return you a ElementFinder
and not ElementArrayFinder
. you need to use product.all()
instead of product.element()
. Look at below example.
prod.all(by.css(".product-ordering ul li")).each(function(elem) {
})
Upvotes: 3