Codeception: jQuery Chosen Dropdown selection with search option

Created on 24 Feb 2016  路  2Comments  路  Source: Codeception/Codeception

hi there i am unable to pick the Country from the following 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 result-selected" 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>

clipboard01
PS: I have Firefox webdriver

WebDriver

Most helpful comment

Ok, so here is how i get the workout which seems a bit suitable

$I->click(['css' => 'div#Merchantserviceproviders_country_chosen']); **-->clicking the dropdown**
$I->fillField(['xpath' => '//div[@id="Merchantserviceproviders_country_chosen"]/div/div/input'], 'United States'); **-->searching the desired country**
$I->click(['xpath' => '//div[@id="Merchantserviceproviders_country_chosen"]/div/ul/li[1]']); **-->click the search result**

All 2 comments

well i have manage to select the country.,, from the following code but its certainly not the perfect solution

$I->click(['css' => 'div#Merchantserviceproviders_country_chosen']);
$I->click(['xpath' => '//div[@id="Merchantserviceproviders_country_chosen"]/div/ul/li[2]']);

In the above code; the value is selected on the placement of the object, so if required value placement changes then we will not get the right value

Ok, so here is how i get the workout which seems a bit suitable

$I->click(['css' => 'div#Merchantserviceproviders_country_chosen']); **-->clicking the dropdown**
$I->fillField(['xpath' => '//div[@id="Merchantserviceproviders_country_chosen"]/div/div/input'], 'United States'); **-->searching the desired country**
$I->click(['xpath' => '//div[@id="Merchantserviceproviders_country_chosen"]/div/ul/li[1]']); **-->click the search result**
Was this page helpful?
0 / 5 - 0 ratings

Related issues

schmunk42 picture schmunk42  路  3Comments

raistlin picture raistlin  路  3Comments

sebastianneubert picture sebastianneubert  路  3Comments

maxibello picture maxibello  路  3Comments

gimler picture gimler  路  3Comments