简体   繁体   中英

How to automate kendo ui dropdown using webdriver/ java

I am new to kendo and selenium webdriver, I just need to automate the kendo ui drop down list , I am able to list the drop down option but I'm not able to select the value. If I tried to select the value am getting an error. I have listed the code used to identify the value

driver.findElement(By.cssSelector("span.k-input")).click();
driver.findElement(By.cssSelector("li.k-item.k-state-selected.k-state-focused")).click();

You have not share your html code so see below general answer to solve your issue.

Please check following :

Syntax :

   //SELECT SPECIFIC VALUE FROM DROPDOWN
   Select sel = new Select(driver.findElement(By.id("yourdropdownid")));
   sel.selectByVisibleText("valueofdropdownoption");

Example :

   //SELECT SPECIFIC VALUE FROM DROPDOWN
   Select sel = new Select(driver.findElement(By.id("continents")));
   sel.selectByVisibleText("Australia");

Note : you can use any like id , css selector ,xpath , class to find element.

Also I would like to point you to kendo ui demo using web driver :

 driver.get("http://demos.kendoui.com/web/dropdownlist/index.html");

 driver.findElement(By.xpath("//*[@id='options']/span[1]/span/span[1]")).click();

 driver.findElement(By.xpath("//*[@id='color_listbox']/li[2]")).click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM