I'm very new to Ruby, Selenium, and UI automation, and have a quick question on how to get a count of visible items in a drop down menu.
Example: I have a drop down menu of 10 currency values (USD, EUR, JPN, etc.). They're coded as:
<div class="list_item">Currency Symbol</div>
The drop down menu is searchable, and if I type in "USD", then the only visible item would be that particular currency value. All other div of that class get a style="display: none;"
attribute. How do I verify that that USD indeed is the only item in the menu? An example of such a situation can be seen here: https://www.oanda.com/currency/converter/
Conceptually, I was thinking of doing this:
- Iterate through each
div
tag withclass=List_item
, and if I find one that has a display, count it. Then verify if it equals to '1'.
I tried using find_elements
but can't seem to find attribute within each element in the array (is it because they aren't webdriver objects?).
If there's another better approach, it'd be really good to know and learn more as well. Appreciate any responses.