Reputation: 5
<div class="subtab">
<button class="ui-multiselect ui-widget ui-state-default ui-corner-all" type="button" aria-haspopup="true" style="width: 231px;">
<span class="ui-icon ui-icon-triangle-2-n-s"></span>
<span>None</span>
</button>
<button class="ui-multiselect ui-widget ui-state-default ui-corner-all" type="button" aria-haspopup="true" style="width: 231px;">
<span class="ui-icon ui-icon-triangle-2-n-s"></span>
<span>None</span>
</button>
</div>
This is 2 drop down menu (the first one is right above the second one). They both have the exact same attribute. How do I specify which one to click on? I'm not even sure why they have the same exact attributes but they do.
Upvotes: 0
Views: 506
Reputation: 46836
You can use the :index locator to specify which of the matching elements is returned. For example :index => 0
will return the first matching element, :index => 1
will return the second matching element, etc. Note that the :index is 0-based (ie starts at 0).
# To click the first one
browser.button(:class => class="ui-multiselect", :index => 0).click
# To click the second one
browser.button(:class => class="ui-multiselect", :index => 1).click
Upvotes: 1