Not able to Handle Kendo Dropdownlist using Selenium

243 Views Asked by At

Hi I am not able to select drop-down option..

Sampe Dropdown : https://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/

I wanted to select anything from dropdown Image

I am able to click on drop-down and all menus are visible but not able to select any option.

enter image description here

I am trying to find xpath for the list as I click on Kendo-Popupenter image description here

it disappear.

2

There are 2 best solutions below

0
AbdeLhalimSB On

this is not the best approach but it works fine.

import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import selenium.webdriver

link = "https://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/"
driver = selenium.webdriver.Chrome()  
driver.get(link)
time.sleep(7)

driver.implicitly_wait(10)
action = ActionChains(driver)
action.scroll_to_element(driver.find_element('id','toc-key-features')).perform()
driver.switch_to.frame(driver.find_element('xpath','//*[@id="gatsby-focus-wrapper"]/main/div[1]/div[2]/article/div[3]/div/div[2]/div/iframe'))
driver.find_element("class name","k-input-value-text").click()
driver.find_element('xpath','//*[text()=\'Chicago\']').click()
time.sleep(2000)
1
Murat Ishenbaev On

this snippet might be helpful:

    driver.get("https://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/")

    dropdown = driver.find_element(By.CSS_SELECTOR, "kendo-dropdownlist span.k- 
    input")
    dropdown.click()

    options = WebDriverWait(driver, 
    10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "kendo- 
    popup ul.k-list li.k-item")))

    desired_option = driver.find_element(By.XPATH, "//li[contains(text(), 
    'Option 1')]")
    desired_option.click()

so first you click on the dropdown to expand it and make the options visible, try to locate the desired option using an appropriate locator (xpath, CSS selector, etc.), in this case it is cs selector, after doing that just click on the desired option to select it. let us know if that is helpful, if not provide us what went wrong :D