【问题标题】:Not able to select Kendo UI + Angular JS dropdown list python selenium无法选择 Kendo UI + Angular JS 下拉列表 python selenium
【发布时间】:2020-08-06 09:13:02
【问题描述】:

您好,我无法选择下拉选项..

示例下拉列表:https://demos.telerik.com/kendo-ui/dropdownlist/angular

我想选择 'STATIC DAT' 作为 'Austria' sung selenium python。

我可以点击下拉菜单,所有菜单都可见,但无法选择任何选项。

我试过的示例代码:

        xpath = r'/html/body/div[4]/div[2]/div[2]/div/div/span[1]/span/span[2]'
        element_inst = web_driver.find_element_by_xpath(xpath)
        # Click dropdown list
        psu.perform_action(web_driver, element_inst, 'click')
        # Select option
        web_driver.find_element_by_xpath("//span[text()='Austria']").click()

有什么解决办法吗?谢谢

【问题讨论】:

    标签: python python-3.x selenium selenium-webdriver selenium-chromedriver


    【解决方案1】:

    您可以尝试以下示例。

    dropdown = web_driver.find_element_by_xpath("//span[@class='k-widget k-dropdown']//span[text()='Albania']") // we depend on default country in list
    dropdown.click() // trigger the dropdown
    
    country = web_driver.find_element_by_xpath("//div[@class='k-list-scroller']/ul/li[text()='Austria']")
    country.click() // select the country
    

    或尝试仅使用“选择”标签(不确定是否会正常显示:无)

    selectCountry = web_driver.find_element_by_xpath("//select/option[@value='Austria']")
    selectCountry.click();
    

    如果不能正常选择元素,试试jsclick

    web_driver.execute_script("arguments[0].click();", selectCountry)
    

    【讨论】:

    • 嗨,当我尝试第二种方法时,我收到错误 Error : Message: element not interactable: Element is not currently visible and may not be manipulated
    • 添加了jsclick示例
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 2021-05-24
    • 1970-01-01
    相关资源
    最近更新 更多