unable to select the drop down list in selenium webdriver in java -


this selenium webdriver code

package com.ej.zob.modules; import org.openqa.selenium.by; import org.openqa.selenium.support.ui.select; public class employee { public void execute(string toplink,string username,string password,string email,string createdon, string rolename,string firstname,string lastname, string company, string phone ){ launchapplication.driver.findelement(by.classname(toplink)).click(); launchapplication.driver.findelement(by.id("field-username")).sendkeys(username); launchapplication.driver.findelement(by.id("field-password")).sendkeys(password); launchapplication.driver.findelement(by.id("field-email")).sendkeys(email); launchapplication.driver.findelement(by.id("field-created_on")).sendkeys(createdon); //launchapplication.driver.findelement(by.tagname("") launchapplication.driver.findelement(by.linktext("select role name")).click(); launchapplication.driver.findelements(by.id("field-role_name")); //launchapplication.driver.findelement(by.classname("chzn-drop")); //sel.selectbyindex(5); //sel.selectbyvisibletext(rolename); launchapplication.driver.findelement(by.id("field-first_name")).sendkeys(firstname); launchapplication.driver.findelement(by.id("field-last_name")).sendkeys(lastname); launchapplication.driver.findelement(by.id("field-company")).sendkeys(company); launchapplication.driver.findelement(by.id("field-phone")).sendkeys(phone); //launchapplication.driver.findelement(by.id("form-button-save")).click(); }  } 

this html code

<select id="field-role_name" class="chosen-select chzn-done"  data-placeholder="select role name" name="role_name"  style="display: none;">  <option value=""></option> <option value="admin"></option> <option value="bm"></option> <option value="sm"></option> <option value="bt"></option> <option value="itop"></option> <option value="guest"></option> <option value="coh"></option> <option value="beop"></option> <option value="sa"></option> </select> 

i want select value drop down "admin". check code of field-role_name wrote findelemnts(by.id("field-role_name")) , because of drop down opening not selecting value how select value.

use below webdriver code select value drop down list in scenario:

new select(driver.findelement(by.id("field-role_name"))).selectbyvalue("admin"); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -