html - Selenium C# dropdown list selecting values -


i'm having problems populating drop down list selenium webdriver on c#.

here html code:

<div class="chosen-container chosen-container-single chosen-container-single-nosearch" style="width: 278px;" title="" id="phmain_0_phcontent_4_ddljobtype_chosen">     <a tabindex="-1" class="chosen-single">         <span>fabricator</span>         <div><b></b></div>     </a>     <div class="chosen-drop">     <div class="chosen-search">         <input type="text" autocomplete="off" readonly=""></div>         <ul class="chosen-results">             <li class="active-result" style="" data-option-array-index="1">fabricator</li>             <li class="active-result" style="" data-option-array-index="2">postformer</li>             <li class="active-result" style="" data-option-array-index="3">retailer</li></ul>         </div>     </div> 

selectelement can not used since there no <select> tag.

i have tried selecting xpath of <li> element, without luck:

var jobtypeinput = driver.instance.findelement(by.xpath("/html/body/form/div[4]/div[2]/section/div[2]/div[1]/div[3]/fieldset[1]/div[4]/div/div/ul/li[1]")); jobtypeinput.click(); 

getting error:

unable locate element: {"method":"xpath","selector":"/html/body/form/div[4]/div[2]/section/div[2]/div[1]/div[3]/fieldset[1]/div[4]/div/div/ul/li[1]"}

any ideas on how populate drop down list 1 of it's 3 values?

i can't directly answer why findelement isn't getting element, have few recommendations.

is xpath absolutely necessary here? using css selector or searching linktext?

i try doing:

driver.instance.findelements(by.cssselector(".active-result"))[1] ;  

have ever used chrome extension "selector gadget"? it's pretty great things this.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -