1

The elements:

<div>class="product-image-container"</div> 
<br>
<br> 

The code:

countMaterials(){  
  let countItems = 0;
  cy.get('#center_column').find("div").then((items) => {
    countItems = items.length;
  });
  return countItems;
}

I'm trying to make it dynamic.

Moustapha
  • 143
  • 6
yuv
  • 139
  • 1
  • 1
  • 5

1 Answers1

0

You can use aliases as well to get the count and then access it later something like:

cy.get('#center_column').find('div').its('length').as('itemLength')

cy.get('@itemLength').then((itemLength) => {
  cy.log(itemLength) //prints itemLength
  // Access itemLength here
})
Alapan Das
  • 17,144
  • 3
  • 29
  • 52