Reputation: 681
Below is the code snippet of my cypress test.
cy.visit("https://harvesthq.github.io/chosen/");
cy.wait(4000);
cy.get('a.chosen-single').click();
cy.get('ul.chosen-results')
cy.get('li').first().click();
The following code visits the given link and opens the select option ( Choosen jquery plugin). But the code fails to select the option.
How can I select the option here ?
Upvotes: 0
Views: 204
Reputation: 17027
a.chosen-single
is not unique there are at least two descriptors: use cy.get('a.chosen-single:first').click();
or use id..
the two parts:
<div class="chosen-container chosen-container-single" title="" id="single_label_example_chosen" style="width: 350px;">
<a class="chosen-single">
<span>American Black Bear</span>
<div><b></b></div>
</a>
<div class="chosen-container chosen-container-single" title="" style="width: 95%;">
<a class="chosen-single">
<span>American Black Bear</span>
<div><b></b></div>
</a>
Upvotes: 1