I have a scenario where there are repeating elements with classname .product-tile
and I am trying to get the elements by that class name and loop through each of them and finding the element whose title is Products
.
If so, I'm trying clicking on apt-add-to-cart-button
, but here the code isn't going in for loop.
var products = element.all(by.css('.product-tile'));
for (var i = 0; i < products.length; i++) {
console.log(i);
var product = products.get(0);
if (product.element(by.css('.productName .title')).getText() === 'Products') {
product.element(by.css('apt-add-to-cart-button')).click();
}
}
html :
Any help would be appreciated.