Saw few questions about this but I think that they are not giving the answer that I'm seeking since all of them were using Select class and I can't use that class since the drop-down is not using select tag.
So I can click and I can display all the options that are available in my drop-down list but I can't display the count for all of them.
I have this code for displaying all the options of my drop-down
List<WebElement> allText = driver.findElements(By.xpath("/html/body/div/div/div[3]/div/div/div[2]/div[2]/div[1]/div[3]/form/div/ul/li[1]/span/ul"));
for ( WebElement element: allText) {
System.out.println(element.getText());
}
but I can't display count for all the options in the list. I used this
System.out.println(allText.size());
on different places in the codebut it always showed 1. What should I use in order to show the count for all the elements in the drop-down ?
The HTML for the list looks something like this
<ul class="dropdown-menu" role="menu">
<li><a pid="null" ng-click="option = null" href="">Option 0</a></li>
<li><a pid="1" ng-click="option = 1" href="">Option 1</a></li>
<li><a pid="2" ng-click="option = 2" href="">Option 2</a></li>
<li><a pid="3" ng-click="option = 3" href="">Option 3</a></li>
<li><a pid="4" ng-click="option = 4" href="">Option 4</a></li>
</ul>
So I need to get the number 5 for the count.