Hello i m trying to pick a value from jQuery Chosed Dropdown using codeception scripting, following is dev code
<div class="chosen-container chosen-container-single chosen-container-active" style="width: inherit;" title="" id="Merchantserviceproviders_country_chosen">
<a tabindex="-1" class="chosen-single"><span>United States</span><div><b></b></div></a>
<div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off"></div>
<ul class="chosen-results">
<li class="active-result" style="" data-option-array-index="0">Please select country</li>
<li class="active-result" style="" data-option-array-index="1">United States</li>
<li class="active-result" style="" data-option-array-index="2">Canada</li>
<li class="active-result" style="" data-option-array-index="3">United Kingdom</li>
<li class="active-result" style="" data-option-array-index="4">Ireland</li>
<li class="active-result" style="" data-option-array-index="5">South Africa</li>
<li class="active-result" style="" data-option-array-index="6">Turkey</li></ul></div></div>
<span class="note"><div style="display:none" id="Merchantserviceproviders_country_em_" class="errorMessage"></div></span></div>
Although i am able to select it using xpath via following;(United Stated in this case)
$I->click(['css' => 'div#Merchantserviceproviders_country_chosen']);
$I->click(['xpath' => '//div[@id="Merchantserviceproviders_country_chosen"]/div/ul/li[2]']);
But the issue is that the selection is through position of the value in the list, so as if any new value(country is added) i will not be able to select it until i know its placement.
I want to know how would i be able to select the country using its Value(United States in my case) not the placement in the list.
Aucun commentaire:
Enregistrer un commentaire