Re: Kendo DropDownList SelectElement

5,142 views
Skip to first unread message

Nick

unread,
Jan 6, 2013, 5:34:52 PM1/6/13
to seleniu...@googlegroups.com
Hi,

Selenium doesn't provide build in methods to manipulate with aggregated html controls like that, you have to write such a methods for your application using available in Selenium operations.

You can start from inspection of html code which represent Kendo DropDownList, you will find that it's not simple html <input ... > but something more complex. You will probably have to start from click on dropdown box, then find dynamically created list of options and click on required option.

On Friday, January 4, 2013 8:33:50 AM UTC+11, German Giunta wrote:
Hi guys,

I'm unable to select a value from a Kendo UI DropDownList control (http://docs.kendoui.com/api/web/dropdownlist), I'm pretty sure it's not supported by selenium.

I'm not an expert with Selenium, is there a way to workaround this? I know Kendo it's pretty new stuff, but maybe there's a way to handle this kind of issues with not supported controllers.

Please let me know if you need more information.

Thanks,
Germán.

Andy Doan

unread,
Jan 7, 2013, 8:08:16 PM1/7/13
to seleniu...@googlegroups.com
Germán,
Try this.
Click the dropdown widget first, then click the k-item.

Because Kendo creates many similar elements with the same class names, you have to use driver.findElements to find all matching elements and then  iterate through them to find the one you need.

Kendo has a great demo page!


        WebDriver driver = new FirefoxDriver();

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

       
WebElement firstDropDown = driver.findElement(By.cssSelector("span.k-widget"));

        firstDropDown
.click();

       
List<WebElement> options = driver.findElements(By.cssSelector("div.k-list-container ul.k-list li.k-item"));

       
for (Iterator<WebElement> iterator = options.iterator(); iterator.hasNext();) {
           
WebElement webElement = (WebElement) iterator.next();
           
if (webElement.getText().equals("Orange"))
                webElement
.click();        
       
}
       
       
       
WebElement secondDropDown = driver.findElements(By.cssSelector("span.k-widget")).get(1);
       
        secondDropDown
.click();

        options
= driver.findElements(By.cssSelector("div.k-list-container ul.k-list li.k-item"));

       
for (Iterator<WebElement> iterator = options.iterator(); iterator.hasNext();) {
           
WebElement webElement = (WebElement) iterator.next();
           
if (webElement.getText().equals("L - 7 1/8\""))
                webElement
.click();        
       
}
       
       
//Close the browser
       
//driver.quit();

-Andy

Oscar Rieken

unread,
Jan 8, 2013, 7:35:23 AM1/8/13
to seleniu...@googlegroups.com
that would work or you can ask the devs to wrap the select elements in a div with an id that you can find then find the span inside of the div

what happens under the covers is that they wrap these spans around the original element 
the spans also have specific attributes like aria-activedescendant="color_option_selected" and aria-owns="color_listbox" that you can probably use in the filtering instead of using the index of the collection

I opted to wrap them in a div since i didnt want to dig too deep into it

here is an example in watir-webdriver

the actual code #cap_color and #cap_size are the divs i used to wrap around the elements kendo ui uses to inject its drop down list
the spec





--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/Iv5nUihA3vUJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Andy Doan

unread,
Jan 8, 2013, 1:06:00 PM1/8/13
to seleniu...@googlegroups.com
+1 Oscar

Sridhar Karra

unread,
Nov 3, 2014, 4:45:29 PM11/3/14
to seleniu...@googlegroups.com
Hello,

I am automating a KENDO UI dropdown using selenium ruby. I am new to selenium ruby and also Kendo. Can you help with how to automate the kendo UI dropdown using selenium ruby. Attached is a screenshot of html elements.

Here is what I have. I was hoping to print the values in options first to see if it captured values correctly and it is printing number of elements like this: "<Selenium::WebDriver::Element:0x379d760>". I don't know how to convert this into text (i tried options.text and it didn't work) and then how to loop through the text?

firstdropdown = @driver.find_element(:xpath, "//div[2]/div/div/span/span/span")
firstdropdown.click()
options = @driver.find_elements(:css, "k-item k-state-selected k-state-focused")
puts options

Any help is greatly appreciated.
Thanks
Sri

On Thursday, January 3, 2013 3:33:50 PM UTC-6, German Giunta wrote:
Hi guys,

I'm unable to select a value from a Kendo UI DropDownList (http://docs.kendoui.com/api/web/dropdownlist), I'm pretty sure it's not supported by selenium.
kendo ui.jpg

Krishna Reddy Gtpv

unread,
Nov 3, 2014, 11:31:26 PM11/3/14
to seleniu...@googlegroups.com
Hi,

I also faced same problem,

I found one solution for that,
1. First click on dropdown list then again click on "3hours". it would be worked out fine. .

Here select method not supports.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.



--
Thanks & Regards
Krishna Reddy Gtpv | Software Engineer | Anblicks Solutions Pvt Ltd
Blog : www.gtpvkr.in  | E Id  : gtp...@gmail.com | Ph : +91 - 9494585126

   




Oscar Rieken

unread,
Nov 5, 2014, 9:59:16 PM11/5/14
to seleniu...@googlegroups.com

Navneet Kumar Pandey

unread,
Sep 2, 2016, 12:12:37 AM9/2/16
to Selenium Users
Hi,

I copied and ran the exact code and got following error.


Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 22765
Only local connections are allowed.
[comment]: SUCCESS: Assembly.Load(ProcMonInject, Version=2.7.5159.0, Culture=neutral, PublicKeyToken=d34a061f079be347)
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible
  (Session info: chrome=52.0.2743.116)
  (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 376 milliseconds
Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'
System info: host: 'navneetk-w08', ip: '172.27.187.64', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4), userDataDir=C:\Users\navneetk\AppData\Local\Temp\scoped_dir18204_2763}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=52.0.2743.116, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: a47662b0ff32c91fea1345d65c309380
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
at automation.dropdown.main(dropdown.java:20)

Shawn Walker

unread,
Mar 11, 2019, 2:34:09 AM3/11/19
to Selenium Users
Try giving this guy a shot.

public void ResetKendoDropdown(string identifier, string defaultText)
{
var kendoElement = _driver.FindElement(By.Id(identifier));

kendoElement.Click();

while (kendoElement.FindElement(By.ClassName("k-dropdown-wrap")).Text != defaultText)
{
kendoElement.FindElement(By.ClassName("k-dropdown-wrap")).SendKeys(Keys.ArrowUp);
}

kendoElement.Click();
}
Reply all
Reply to author
Forward
0 new messages