Javasccript: Get all tag elements

A short script but it will help you to debug your javascript/automation issues:

var allElements = document.getElementsByTagName("span");

    total=0;
    for(var i=0; i < allElements.length; i++)
    {
        if  (allElements [i].className.includes("ng-option-label ng-star-inserted"))
        {
       // console.log(allElements [i].className);
        console.log(allElements [i].textContent );
        total++;
        }
    }
    console.log("Total Item: "+total);

Leave a Reply

Your email address will not be published. Required fields are marked *