Count element
Last updated
Was this helpful?
This action helps the tool scan the webpage to see how many items match the "name" (XPath) you provided, then store that total number in a variable.
Effect: Very useful when you want to check the number of products displayed, count the number of comments, or check if a list has loaded enough data. If the count is 0, it means no items were found; if the count is more than 0, you can use loops to process each item sequentially.
🎥 See more tutorial video: Here.
XPath: The XPath identifier path of the set of elements you want to count on the webpage interface.
Output variable: The name of the variable to store the counted result (Returns an integer: 0, 1, 2, 3,...).
When you access the mobile phone store page as shown in the image, you want the script to automatically check how many products are currently displayed on the page to set the number of interaction loops or scrape data accurately:
Looking at the source code structure, each product cell is contained within a div tag with the attribute class="card h-100". You configure the action as follows:
Element XPath: Enter the common XPath path of the product cells: //div[@class="card h-100"]
Output variable: Name the output variable totalProducts.
Result: The system will scan the entire webpage and count how many tags match the above XPath. For example, if 9 products are displayed on the screen, the variable $totalProducts will receive the value 9.
💡 Advanced application: You can use this quantity variable to pass into the configuration of the For loop, allowing the script to automatically loop exactly
9times to click for details or scrape sufficient information for all 9 products without excess or omission.


Last updated
Was this helpful?
Was this helpful?