I am using Rspec and Watir-webdriver and am looking to get a count of all the elements that have been clicked.
What I'm doing:
I perform a search and get back a list of results; I then run a loop to select only 5 of them. The class name for these elements goes from asset-card selectable
to now saying asset-card selectable selected
.
I try to get a proper count by doing this:
count = @browser.elements(:class, 'selected').size
But this is still giving me all results and not specifically the ones that now have selected
as part of the class name.
Any thoughts on how I can accomplish this?
This is what the html looks like:
<div class="search results">
<div class="asset-card selectable selected"></div>
<div class="asset-card selectable selected"></div>
<div class="asset-card selectable"></div>
<div class="asset-card selectable"></div>
<div class="asset-card selectable"></div>
</div>
In this html example, the first two elements have been selected